I am trying to use rstring option for http-check to validate if service is 100% operational.
What I am trying to do:
http-check expect rstring ^{"status":"UP","components"
Response from endpoint:
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"Microsoft SQL Server","validationQuery":"isValid()"}},"diskSpace":{"status":"UP","details":{"total":57470816256,"free":16902025216,"threshold":10485760,"exists":true}},"hikariConnectionPool":{"status":"UP","details":{"activeConnections":0,"maxPoolSize":40}},"indexStatus":{"status":"GREEN"},"ping":{"status":"UP"}}
regex ^{“status”:“UP”,“components” should be ok, but I guess I am missing something.
Please read about 2.2. Quoting and escaping in the manual.
thank you for help @lukastribus. I am still getting issues with detection.
balance roundrobin
option redispatch
option httpchk
option httpchk GET /resthealth/
#http-check expect status 200-404
http-check expect rstring ((^{\"status\":{\"code\":\"UP\")|(^{\"status\":{\"code\":\"DEGRADED\"))
{"status":{"code":"DEGRADED","description":""},"details":{"dbConnectionPool":{"status":{"code":"DEGRADED","description":""},"details":{"DB active pool size":53,"DB max pool size":80}},"administrationAutoTaskCreator":{"status":{"code":"UP","description":""},"details":{"description":"Fails if administration task creator job did not complete successfully in the last 30 hours."}},"diskSpace":{"status":{"code":"UP","description":""},"details":{"total":57470816256,"free":16898035712,"threshold":10485760}},"db":{"status":{"code":"UP","description":""},"details":{"database":"Microsoft SQL Server","hello":1}},"refreshScope":{"status":{"code":"UP","description":""},"details":{}}}}
this is for HaProxy wrong reponse code and it puts enpoint as down. Which is strange. If status is “UP” and not “DEGRADED”, that it is fine. What else could be wrong?
Provide the output of haproxy -vv
, regexp matching depends on external libraries or falls back to a simpler libc implementation, which may not have all the features.
I don’t see anything wrong with the regexp.
Can you try changing the order (DEGRADED first, UP after), just to see this matches DEGRADED but stops matching UP, or if it is the same:
http-check expect rstring ((^{\"status\":{\"code\":\"DEGRADED\")|(^{\"status\":{\"code\":\"UP\"))
A complete HTTP capture of the health check traffic could be required if none of the above helps, to see if the response is actually what we think it is.