I’m trying to use Use Uptime Tests with Target URL, but I don’t know exacly how it works…
I add uptime tests that match the URL in upstream targets.
Tyk will create a list of all failed uptime-test hosts. If one upstream target matches a host on the list, it will skip this host? Does this always have to match? Because my upstream target may be http://host, but there is no page so I would have to create a test against http://host/core.
Is it possible to see the current ‘down’-host list somehow?
You basically set up a bunch of test URLs for your service, e.g.:
And then Tyk will ping those hosts for you with those requests and payloads, now you don;t need to always have the same host, or the same endpoint, you could set up a test for all of your services and Tyk willg enerate an uptime chart of the latency and availability for you.
To know when a host is down, you need to hook into the
HostDown event, which fires if a URL starts to fail.
If you are using the load balancer, then you can enable an option for Tyk to link the two and remove the hostname from the loadbalancer so that no more traffic hits that hostname until the uptime tet passes again.
If you want them to be linked, the hostnames must match, not the URLs
This would work
You would need to hook into the
HostDown events which can generate a webhook or run some JS.
I try to make it concrete:
I have this Load Balancer Targets:
with these upstime tests
GET : http://myHost1:19081/LoginApplication/LoginService/swagger/ui
GET : http://myHost2:19081/LoginApplication/LoginService/swagger/ui
GET : http://myHost3:19081/LoginApplication/LoginService/swagger/ui
I checked the [x] Check host against downtime list
I restart the myHost1 machine and in the uptime targets, I see
http://myHost1:19081/LoginApplication/LoginService/swagger/ui 14 success 16 errors
http://myHost2:19081/LoginApplication/LoginService/swagger/ui 29 success 1 errors
http://myHost3:19081/LoginApplication/LoginService/swagger/ui 29 success 1 errors
My expectation would be that the load balancer only redirects to host2 and host3, but if I make a request to the api, every 3rd fails.
Is it possible to specify a header in endpoint designer that logs to which load balancer target the request was directed?
Before trying to get the LB to work, you should probably check your gateway logs to make sure the host checker is active (it should be), you should also see error logs when the host is detected as down and up again. If you can see these, then the host checker is working properly.
Once you.ve confirmed that, then try the uptime link with the LB.