All namespaces metrics not being displayed

I have a chart in Grafana that uses this metric and a custom label (the metric comes from an exporter called opa-scorecard):

I have a namespace variable/drop-down menu, and when I check the individual namespaces via the dropdown, it works fine, and I get to view the violation metrics for each namespace individually.

However, I’ve added an All option, as I want to have the option to view all violations from every namespace together. I added this config in the namespace variable to allow me to do that:

image

But when I then select the All option in the namespace dropdown, no violations are displayed.

I’ve tried this both with and without Custom all values populated, but with no luck.

Does anyone have any idea why this would not show me metrics from all namespace with this configuration?

I solved the issue. For anyone who has a similar issue, the problem was the metric.

I just needed to replace:
opa_scorecard_constraint_violations{violating_namespace="$namespace"}
with:
opa_scorecard_constraint_violations{violating_namespace=~"$namespace"}

1 Like

For anyone wondering what the difference is - the second version uses regex matching for label matching.

This section of the docs for LogQL describes the log stream selector and the label matching operator: LogQL | Grafana Labs