- What Grafana version and what operating system are you using?
9.3.6. It’s on a docker image with a postgres server.
- What are you trying to achieve?
I know it’s not a traditional use case, but we are building a dashboard with custom UI elements and embedded grafana iframes. The UI/UX needs are pretty complex and the dashboard needs to be integrated with another web app.
I’m trying to get some pointers on how to use the variables functionality.
- How are you trying to achieve it?
For filtering, I’m stringifying a UI state into a bunch of key : value
pairs, and sending it as a query variable like var-filters={stringified_key_value_pairs}
.
When no filter is selected on the front end, the var-filters
could be empty. Plus, not selected values are also empty, as the key would not exist.
I’m trying to handle these filters in the query code editor, but I’m struggling to handle cases when:
$filters itself is empty, or
a key of $filters is empty.
I have tried: $filters IS NULL, $filter = '', $filter IN ('', ' ')
- What happened?
Database errors out.
- What did you expect to happen?
Maybe my syntax is wrong, but I’m hoping to be able to handle empty cases.
- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
This is the error from the Query Inspector: Cannot read properties of null (reading 'replace')
I understand the error message itself, but I’m not sure how to fix it.
- Did you follow any online instructions? If so, what is the URL?
I tried to look at the Variable Syntax documentation. Variable syntax | Grafana documentation