0

I have a single grafana dashboard. In that dashboard, there are two panels, both of which are tables. I want to implement a search feature i.e. I want to ideally have a search box at the top of the dashboard and whatever user types in that search box is looked up in both those tables and every row which has that search query in EVEN ONE of it's column values is filtered in.

I looked up searching in grafana online and couldn't really find anything that met my needs.

1 Answers1

0

As of version 9 of Grafana there is no easy way to implement this.

You can create variable of the type "Text box" and use it for filtering. Rather nice approach in this case would be to use "Filter data by values" transformation with "match any" and all columns listed with regex filter .*$query.*, but Grafana 9 (and older versions) doesn't support variables in transformations.

There considerations to add support for this in Grafana 10, AFAIK. You can follow news about it in this issue.


If you are lucky, you can embed your variable into query for data. Possibility of this will depend on your data source and complexity of current query.

Here are examples for a couple of data sources: Prometheus and SQL type data source (for example MySQL):

If it's rather simple metric query to Prometheus, for example something like

node_systemd_version{env="demo"}

you could convert it to

node_systemd_version{env="demo", env=~".*$query.*"} 
 or node_systemd_version{env="demo", job=~".*$query.*"} 
 or node_systemd_version{env="demo", instance=~".*$query.*"}

In case of SQL type data source you could add something like

AND (
  column1 like '%${query}%'
  OR column2 like '%${query}%'
  OR column3 like '%${query}%'
)
markalex
  • 8,623
  • 2
  • 7
  • 32
  • In my case, the data source for the first table is an API that returns data in simpleJSON plugin format. And the data source for the next table is mixed(cortex and API). I take both these data and perform an inner join. The final result is what needs to be searched. I would like to do searching in the end as making changes to the data source isn't under my control. – Ashutosh Kumar May 29 '23 at 03:54
  • @AshutoshKumar, then AFAIK your task couldn't be implemented. Follow linked issue, and hope that 10 will allow to use variables in transformations. – markalex May 29 '23 at 05:05