chaostoolkit-prometheus icon indicating copy to clipboard operation
chaostoolkit-prometheus copied to clipboard

Allow unwrapping scalar Prometheus values

Open benpankow opened this issue 4 years ago • 0 comments

Prometheus returns scalar values as strings in order to support NaN, Inf, and -Inf. Unfortunately, this makes it quite difficult to use the Toolkit's jsonpath support to filter based on these scalar values, as jsonpath2 does not perform comparisons between numbers and numbers formatted as strings.

I would like to use the following tolerance to ensure a metric is within a certain range:

{
    "type": "jsonpath",
    "path": "$.data.result[*][?(@.value[1] > 90)]",
    "count": 1,
    "target": "stdout"
}

In order to do so, I am currently relying on a custom probe script which will fetch the Prometheus metrics and reformat the scalars represented as strings into floating point values. I think this would be useful functionality to have in the Prometheus extension, and it is easier to implement the change here than in jsonpath2.

benpankow avatar Jul 04 '20 23:07 benpankow