I using Grafana to plot data from a MySQL datasource. My question is: is it possible to, in a panel's query editor, use an IF ... THEN ... type statement. I would like to create a variable that I could put in the IF, to use it as a kind of filter.
For example:
//IN THE DATA SOURCE:
CREATE TABLE Example (Data INT);
INSERT INTO Example VALUES (1), (2), (3), (4)
For a variable Test with values 1,2:
//WHAT I'D LIKE IN GRAFANA QUERY EDITOR:
IF($Test = 1) THEN
SELECT * FROM Example
END IF;
I've tried the syntax that's in this example, and it doesn't seem to work as is. Is this kind of condition based query even possible? If so, what is the proper syntax to get it to work? And if not, is there any way I can use Grafana variables to have a similar effect? I've tried just having a bunch of different queries that filter for every condition but it's ugly and not very user friendly.
Any help would be greatly appreciated, thanks.
Aucun commentaire:
Enregistrer un commentaire