Currently blackbox_exporter supports using regular expressions to match the output of an HTTP request. While regular expressions are great for some use cases, they cannot be used in others, like matching JSON values.
It would be nice to have support for JSONPath. Basically introduce another validation that takes a JSONPath expression, an operator (contains, not contains, etc) and a value, and pass/fail based on that.
In order to support this properly, this would have to work with header validations, where you assert that the content-type header has an appropriate value (but I imagine that part would be up to the user to set up correctly).
Currently blackbox_exporter supports using regular expressions to match the output of an HTTP request. While regular expressions are great for some use cases, they cannot be used in others, like matching JSON values.
It would be nice to have support for JSONPath. Basically introduce another validation that takes a JSONPath expression, an operator (contains, not contains, etc) and a value, and pass/fail based on that.
In order to support this properly, this would have to work with header validations, where you assert that the
content-type
header has an appropriate value (but I imagine that part would be up to the user to set up correctly).There's an xpath package (https://github.com/antchfx/xpath) that supports XML, JSON and HTML.
There's an xmlpath package that supports XML and HTML (https://pkg.go.dev/gopkg.in/xmlpath.v2).
And there's a JSONPath package (https://github.com/PaesslerAG/jsonpath).