I'm working with Grafana and using KQL for log queries. I want to incorporate Grafana query variables into my KQL queries to make them more flexible and interactive. However, I'm facing challenges in understanding how to use query variables effectively in Grafana's KQL.
Specifically, I would like to know:
- How to define and use query variables in Grafana's KQL log queries? What syntax should be used to reference query variables in dashboard to the KQL query In Grafana?
- How can I ensure the query variables pass the desired values when i change the value on dashboard that need to refelct KQL query at runtime?
I have already explored the Grafana documentation, but I couldn't find detailed examples or explanations specific to KQL log queries.
I would greatly appreciate any guidance or examples demonstrating the usage of Grafana query variables in KQL log queries.
You can add variable as described in official documentation.
I personally would recommend to start with variables of type "Custom", to see how they are behaving and how they are selected by user of dashboard.
I'm not familiar with KQL. And it is not even clear what it exactly is from your question. For this answer I'll be assuming you're talking about Kusto Query Language.
You can simply replace values of constant parameters in your query with variable (for example
$state
), as per official documentation on variable usage.Grafana substitutes variables automatically. If you have some doubts about it, you can add variable to the name of your panel in the same way as to the query. To something like this:
My panel. Variable state: $state