Uptime Test Endpoint

Hello, I’m trying to set up an uptime test with service discovery (v. 1.9). I have an endpoint returning the following json:

[{“url”:“someUrl:somePort/test?query[0]=test”,“method”:“GET”,“headers”:{“Accept”:“application/json”,“ApiKey”:“someApiKey”, Authorization":“Bearer eyJ0eXAiOiJKV1QiLCJhbGciOi…”},“body”:null}]

and the “Data path” is empty.

In my API definition, the target URL is “/” because I’m also using Service Discovery for this.
Now my docker instance crashes with

time=“2016-04-25T13:04:12Z” level=info msg=“Loading uptime tests…”
time=“2016-04-25T13:04:12Z” level=error msg=“input text could not be parsed”
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4a43a8]

How can I debug this or can anyone tell me what’s wrong with my json?

So our docs on uptime tests state:

The document that Tyk requires is a JSON string encoded version of the check_list parameter of the uptime_tests field

e.g this configuration:

        "url": "http://google.com/"
        "url": "http://posttestserver.com/post.php?dir=uptime-checker",
        "method": "POST",
        "headers": {
          "this": "that",
          "more": "beans"



But your endpoint should return an object, so that we can extract a specific node from the returned value, so:

	service_data: '[{"url":"http://google.com/"},{"url":"http://posttestserver.com/post.php?dir=uptime-checker","method":"POST","headers":{"this":"that","more":"beans"},"body":"VEhJUyBJUyBBIEJPRFkgT0JKRUNUIFRFWFQNCg0KTW9yZSBzdHVmZiBoZXJl"}]''

Then your namespace is just service_data

Hope that makes sense :slight_smile:

Thanks for your instructions, worked now!

1 Like

Is it possible to get this JSON from consul?? I don’t really figure it out …

There may be an issue using consul because it base64-encodes the value in it’s k/v store :-/

If you can avoid the encoding and just get a raw string, then yes, it’s totally possible.