I creates few variables which do not include null values, but when I change the variable selection It can be empty values automatically selected then it cause template errors. I use SQL datasource and SQL queries.
When I design variable there should be “Not Null” option and Grafana should automatically prevent Empty selections to avoid this problem.
Steps to reproduce the problem:
- Create variables and use them in chart’s query in where condition.
- Make selection in variable value’s list. (If you do not use “Include All Option” and use “Multi Value” you can easily uncheck the selection it will be automatically empty value)
- After making selections try go back in your browser few times then you will see the empty values.
Version numbers (grafana, prometheus, graphite, plugins, operating system, etc.):
Grafana v7.5.15 (7dd69b2442)
Maybe I’m way off but are you filtering a Graph with a SQL Fed Variable
Like this “Variable”
SELECT metric
FROM Table
GROUP BY metric
Then in the Graph
SELECT time, metric, value
FROM Table
WHERE metric IN ( $metric )
ORDER BY time DESC
I’ve done similar filters but with Nulls/Blanks in Data I’ve had to handle them myself
-- FILTER
SELECT CASE WHEN metric IS NULL OR metric IN ( '',' ' )
THEN 'BLANK'
ELSE metric
END
FROM Table
GROUP BY metric
-- GRAPH
SELECT time, metric, value
FROM Table
WHERE CASE WHEN metric IS NULL OR metric IN ( '',' ' )
THEN 'BLANK'
ELSE metric
END IN ( $metric )
ORDER BY time DESC
Hope I’m not way off and it’s some help
2 Likes
Do you paid version or OSS?
Does this issues exist in latest version of grafana?
I’ve been struggling with this problem for months and I’m so glad I finally found a solution. Thanks!
1 Like