Hellow everyone. I'm wondering if in dashboards I ...
# general
j
Hellow everyone. I'm wondering if in dashboards I can use the variables for PromQL?
s
Yes, it would be something like this
{service_name="{{.service_name}}"}
where
service_name
is the variable and the part of metric labels.
j
I've defined a uri value "/klt/api/v1/transactions" and tried to use it in PromQL like this:
sum(rate(http_server_requests_seconds_count{uri=~{{.uri}}}[1m]))
And I'm getting the error:
Error: API responded with 400 - encountered multiple errors: error in query-A: parse error at char 50: unexpected character inside braces: '/'
I understand that is because the the var needs to be inside "". So no the question is how can I escape the quotes? I've tried
\"
s
You don’t need to escape the quotes around the variable. Doesn’t this work for you ``sum(rate(http_server_requests_seconds_count{uri=~"{{.uri}}"}[1m]))``?
j
No:
No Data
But there is data, If I put "/klt/api/v1/transactions" I get results
s
Did you select the variable with the value? If you don’t make a selection from the dropdown current state will be none, and no results are shown.
j
@Srikanth Chekuri not sure I understand you. Where should I select the value. In the PromQL I only have a textfield for the query
image.png
s
Save the query and then go to the dashboard and make sure the variable has the value
/klt/api/v1/transactions
j
Query saved...
No data
It worked. I've refreshed the browser. Thanks!
s
It doesn’t require a browser refresh. Did you try the refresh button at the top right?
I am not very sure about the text field type variable query. I will take a look.