https://signoz.io logo
#general
Title
# general
j

Jose Infazon

02/14/2023, 2:07 PM
Hellow everyone. I'm wondering if in dashboards I can use the variables for PromQL?
s

Srikanth Chekuri

02/14/2023, 2:23 PM
Yes, it would be something like this
{service_name="{{.service_name}}"}
where
service_name
is the variable and the part of metric labels.
j

Jose Infazon

02/14/2023, 2:28 PM
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

Srikanth Chekuri

02/14/2023, 2:30 PM
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

Jose Infazon

02/14/2023, 2:31 PM
No:
No Data
But there is data, If I put "/klt/api/v1/transactions" I get results
s

Srikanth Chekuri

02/14/2023, 2:32 PM
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

Jose Infazon

02/14/2023, 2:37 PM
@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

Srikanth Chekuri

02/14/2023, 2:38 PM
Save the query and then go to the dashboard and make sure the variable has the value
/klt/api/v1/transactions
j

Jose Infazon

02/14/2023, 2:41 PM
Query saved...
No data
It worked. I've refreshed the browser. Thanks!
s

Srikanth Chekuri

02/14/2023, 3:00 PM
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.
7 Views