0

I work with an ElasticSearch data source on Grafana 7.15. The data source has a field 'id' of which the type is 'keyword'. I'm trying to use a dynamic variable called 'site' in the JSON query meant to create another dynamic variable, 'id'. Here is the query The objective would be to modify this query so that the 'id' has to contain 'site'. For example, if the other variable 'site' has its value set to 'TORT', one possible id is 'LR_TORT_2354'.

I've tried various syntaxes, but I have no expertise in JSON, and I can't find the documentation for this particular situation anywhere. Thank you for your help!

  • Sorry, could you clarify: you have troubles to write query to elastic, to pass to this query dashboard variable or create new variable based on this query? – markalex Apr 05 '23 at 17:40
  • This query is working, but it displays all the IDs. I would like to add a condition that filters the ID that do not contain the str that is the dashboard variable 'site'. If 'site' is selected as 'TORT' in its drop down menu, I'd like that the other drop down menu with the IDs would only show the corresponding Ids – Daniel Apr 06 '23 at 11:25
  • You can use content of variable in your query as `$site` or `${site}`. Also you can use variables inside queries for other variables, but used variable should be upper in list of variables in dashboard. Hope this helps. – markalex Apr 06 '23 at 11:30
  • Thanks a lot for your answer, it helps. Sorry to ask you that, but I really struggle with these queries, do you think you could show me how you would write it? – Daniel Apr 06 '23 at 12:05
  • I'm not familiar with elastic queries. But I believe with Grafana out of the problem you should fairly easy find some manual on them, write query like you need with fixed value (like `TORT` in your case), and when your paste this query into Grafana replacing `TORT` with `$site` – markalex Apr 06 '23 at 12:18

0 Answers0