I have a dashboard with 3 variables: cluster, namespace and “app”. The two first ones are fairly standard, the last one queries the pod_labels metric to grab available values, like this:
label_values(kube_pod_labels{cluster="$cluster", namespace="$namespace"}, label_app)
one panel is a prometheus metrics panel, where i display cpu usage for pods matching the label from the variable:
sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster="$cluster", namespace="$namespace", container!="POD"} * on(pod) group_left(label_app) topk(1, kube_pod_labels{cluster="$cluster", namespace="$namespace", label_app="$app"}) by (pod)) by (pod, container, label_app)
The other panel is a loki logs panel. I want that panel to show logs from the same pods as my metrics panel is showing. Loki doesn’t have access to kube_pod_labels
as far as I know, so I’m wondering if I can somehow send the “list of pods” from my metrics panel to the loki panel?