I’m doing some work slicing up data which we’ve moved into Postgres. The original source was JSON based, and as a result a number of columns contain JSON objects (or parts of them).
One column is called info and contains JSON object. I’m trying to get a dashboard to filter based on an array in that object called ‘labels’. The contains 0 or more tags e.g.
[“ESB”, “SP”, “MET”]
I’d normally write the query as some like:
WHERE (info->‘labels’)::jsonb ? ‘ESB’
I’m probably making some dumb mistake as I’m brand new to Grafana, but replacing ‘ESB’ with a variable I’ve set up (as either $Label or [[Label]]) i.e
WHERE (info->‘labels’)::jsonb ? $Label
Give me a syntax error. Any help would be gratefully received!
As a secondary question, I’d really like to extend it to filter on more than one label i.e.
WHERE (info->‘labels’)::jsonb ? ‘ESB’ OR (info->‘labels’)::jsonb ? ‘SP’