Search code examples
grafanagrafana-lokilogql

Fill Grafana Dashboard Variable From LoqQL


I have a Grafana dashboard and I'd like to define a variable for this dashboard. I'd like the values of this variable will come from LogQL query. To be more specific - in each log I have a field called "site_ids", and I want the values of the variable to be all the different "site_ids" (longs). So I wrote this query:

{_namespace_="namespace",_schema_="schema"}  | logfmt | line_format "{{.site_ids}}"

Which seems to work when I just run it in the query executor, this is the output (the actual site_ids):

0
-1
196
2
3
...

But when putting it as a query when I try to configure a new variable, I see nothing in the Preview of values:

Grafana screenshot

Unfortunately I can barely find documentation about this..

Any suggestions?

Thanks!


Solution

  • Use label_values like this Query Variable section