I am using MySQL as my data source in Grafana and I am executing SELECT Queries to fetch data
Here is the query that I am executing,
SELECT * FROM [[databases]].[[columns]] limit 0, [[limit]];
I have created 3 variables “databases” , “columns” and “limit” which will give me the appropriate result and I have variablized “databases” and “limit values”
But what I want is when I select the value of database from drop down, the column variable should show tables from selected database only
In the configuration of the [[columns]] template variable, you can have the options in the drop-down be populated by a SQL query (https://grafana.com/docs/reference/templating/#variable-types). In that query itself you can use the [[databases]] variable to run a query that would return the desired set of values for [[columns]]. You may have to experiment with the variable recalculation option, to ensure that the values of [[columns]] are recalculated whenever the user changes their selection of [[databases]].
In [[column]] template variable I am using “show tables;” SQL query.
but when I try to save it, I got an error message like this “Template variables could not be initialized: Error 1046: No database selected”
In [[Database]] template variable I am using “show databases;” SQL query, which works fine and gives me the proper result of the list of databases
Can you please give me an example of how can I merge [[database]] template variable value to [[column]] template variable
I have a similar situation in which am trying to use one variable output to another but seems not working ,Am using InfluxDB
This is the variable
SHOW TAG VALUES WITH KEY=NodeName WHERE NodeName =~ /AJB/ → $cust
Query
SELECT last(“SiteStatus”) as STATE FROM “Bucket” WHERE “agent_host” = ‘NMS1’ AND ( SiteStatus = 2 OR SiteStatus = 3) AND time >= now() -1m GROUP BY NodeName