I've created a Grafana dashboard variable (multi-select enabled) based on a MySQL query:
SELECT DISTINCT(my_field) from my_table
This field has about 12 options, one of them being a NULL value. When editing my dashboard widgets, I include a SQL constraint similar to:
... WHERE my_field IN ($my_variable)
This almost works well, except for the NULLs. Grafana is translating the NULL to '', and NULL isn't supported in an IN (...) statement anyway.
Any recommendations on how to handle this to work with NULLs?
You could extend condition:
WHERE my_field IN ($my_variable) OR my_field IS NULL;
Grafana is translating the NULL to ''
WHERE COALESCE(my_field, '') IN ($my_variable)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With