troubleshoot
troubleshoot copied to clipboard
Extend http analyser to allow inspecting the response body
Describe the rationale for the suggested feature.
The http collector output wraps the response body in a JSON value. There is no clean way to analyse the contents of the body using the http analyser (Not documented in troubleshoot.sh) at the moment. We need to address this by extending the http analyser to allow when values that evaluate against various query implementations such as jsonpath, regex or simple comparisons (==, >= ....)
Describe the feature
Add new when evaluation syntax to allow crafting further queries against the response body. The spec would look like so
Spec
- http:
checkName: health-check
collectorName: health-check
outcomes:
- pass:
when: "body == '{\"status\": \"OK\"}'"
message: ""
- warn:
when: "jsonpath($.status) == 'DEGRADED'"
message: ""
- error:
when: "regexMatch(*service is unhealthy*)"
message: ""
The when operations can be made simpler or different. Its for example not clear from the above spec whether its the body we are comparing with. Alternatives welcome
Collector output
{
"response": {
"status": 200,
"body": "{\"status\": \"DEGRADED\"}",
"headers": {
"Connection": "keep-alive",
"Date": "Fri, 19 Jul 2019 20:13:44 GMT",
"Server": "nginx/1.8.1",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains"
}
}
}
Describe alternatives you've considered
Related issues/PRs
- https://github.com/replicatedhq/troubleshoot-specs/pull/37
- https://github.com/replicatedhq/troubleshoot-specs/pull/36