I'm trying to write a prometheus query in grafana that will select visits_total{route!~"/api/docs/*"}
What I'm trying to say is that it should select all the instances where the route doesn't match /api/docs/*
(regex) but this isn't working. It's actually just selecting all the instances. I tried to force it to select others by doing this:
visits_total{route=~"/api/order/*"}
but it doesn't return anything. I found these operators in the querying basics page of prometheus. What am I doing wrong here?
All regular expressions in Prometheus use RE2 syntax.
Wildcards in queries Prometheus uses a Regex-like pattern and the wildcard character is . + (read: dot plus) combined with tilde character ( ~ ) instead of just the equal sign ( = ). So the query becomes http_status{job~="customer-. +"} .
Click the graph title, then click "Edit". Under the "Metrics" tab, select your Prometheus data source (bottom right). Enter any Prometheus expression into the "Query" field, while using the "Metric" field to lookup metrics via autocompletion.
May be because you have /
in the regex. Try with something like visits_total{route=~".*order.*"}
and see if the result is generated or not.
Try this also,
visits_total{route!~"\/api\/docs\/\*"}
If you want to exclude all the things that has the word docs
you can use below,
visits_total{route!~".*docs.*"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With