Setting Uptime Test with Service Discovery


#1

Hello Tyk Community, help needed on uptime test regarding service discovery.

I am trying to config the uptime test so that my consul service could provide information about upstream health.

Here is my uptime test setting from API definition:
“check_host_against_uptime_tests”: true,
“auth_provider”: {
“name”: “”,
“storage_engine”: “”,
“meta”: {}
},
“blacklisted_ips”: [],
“hmac_allowed_clock_skew”: -1,
“dont_set_quota_on_create”: false,
“uptime_tests”: {
“check_list”: [],
“config”: {
“expire_utime_after”: 0,
“service_discovery”: {
“use_discovery_service”: true,
“query_endpoint”: “http://myconsul.com:8500/v1/health/service/foo?passing=true”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “Service.Address”,
“cache_timeout”: 60
},
“recheck_wait”: 0
}
},

Here is the JSON result(an array of JSON), if you GET “query_endpoint”: “http://my_consul:8500/v1/health/service/foo?passing=true”:
[
{
“Node”: {
“ID”: “fcefc684-2979-4ac0-8217-351b40d122d9”,
“Node”: “2ea3658d722b”,
“Address”: “172.17.0.5”,
“Datacenter”: “dc1”,
“TaggedAddresses”: {
“lan”: “172.17.0.5”,
“wan”: “172.17.0.5”
},
“Meta”: {
“consul-network-segment”: “”
},
“CreateIndex”: 40525,
“ModifyIndex”: 40526
},
“Service”: {
“ID”: “hello1”,
“Service”: “foo”,
“Tags”: [
“primary”
],
“Address”: “myconsul.com”,
“Meta”: null,
“Port”: 4001,
“Weights”: {
“Passing”: 1,
“Warning”: 1
},
“EnableTagOverride”: false,
“ProxyDestination”: “”,
“Proxy”: {},
“Connect”: {},
“CreateIndex”: 40730,
“ModifyIndex”: 40826
},
“Checks”: [
{
“Node”: “2ea3658d722b”,
“CheckID”: “serfHealth”,
“Name”: “Serf Health Status”,
“Status”: “passing”,
“Notes”: “”,
“Output”: “Agent alive and reachable”,
“ServiceID”: “”,
“ServiceName”: “”,
“ServiceTags”: [],
“Definition”: {},
“CreateIndex”: 40525,
“ModifyIndex”: 40525
},
{
“Node”: “2ea3658d722b”,
“CheckID”: “service:hello1”,
“Name”: “Service ‘foo’ check”,
“Status”: “passing”,
“Notes”: “”,
“Output”: “HTTP GET http://localhost:4001/: 200 OK Output: 1:Ok”,
“ServiceID”: “hello1”,
“ServiceName”: “foo”,
“ServiceTags”: [
“primary”
],
“Definition”: {},
“CreateIndex”: 40730,
“ModifyIndex”: 42507
}
]
}
]

After I update my API definition, I get the following error from my tyk-gateway:
level=warning msg=“Get Object: hostname is not a string”
level=error msg="[HOST CHECKER MANAGER] Decoder failed: unexpected end of JSON input"

I have read this and this but none of them explained how to connecting uptime test and service discovery.

Any suggestion and guidance are really appreciated!!