docs: restrict sample scrape job to listener pods

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Nikola Jokic
2026-09-21 11:34:21 +02:00
co-authored by Copilot App
parent cda4aefbf2
commit c19d467407
@@ -45,8 +45,8 @@ __meta_kubernetes_pod_label_actions_github_com_scale_set_namespace=arc-runners
``` ```
The scrape configuration has to copy those metadata labels onto the scraped metrics. The The scrape configuration has to copy those metadata labels onto the scraped metrics. The
example below copies only the two labels the dashboard needs, scoped to the `arc-systems` example below selects only the listener pods in the `arc-systems` namespace and copies only
namespace: the two labels the dashboard needs:
```yaml ```yaml
scrape_configs: scrape_configs:
@@ -57,12 +57,23 @@ scrape_configs:
names: names:
- arc-systems - arc-systems
relabel_configs: relabel_configs:
# Only scrape the listener pods, on their metrics port.
- source_labels: [__meta_kubernetes_pod_label_actions_github_com_scale_set_name]
action: keep
regex: .+
- source_labels: [__meta_kubernetes_pod_container_port_name]
action: keep
regex: metrics
- source_labels: [__meta_kubernetes_pod_label_actions_github_com_scale_set_name] - source_labels: [__meta_kubernetes_pod_label_actions_github_com_scale_set_name]
target_label: actions_github_com_scale_set_name target_label: actions_github_com_scale_set_name
- source_labels: [__meta_kubernetes_pod_label_actions_github_com_scale_set_namespace] - source_labels: [__meta_kubernetes_pod_label_actions_github_com_scale_set_namespace]
target_label: actions_github_com_scale_set_namespace target_label: actions_github_com_scale_set_namespace
``` ```
Without the `keep` rules, Prometheus creates a target for every pod and port in the
namespace, most of which do not serve metrics. If you already have a scrape job for the
listeners, add just the two `target_label` relabelings to it.
If you use the Prometheus Operator, the equivalent is a `PodMonitor` (or `ServiceMonitor`) If you use the Prometheus Operator, the equivalent is a `PodMonitor` (or `ServiceMonitor`)
with the same entries in its `relabelings`. with the same entries in its `relabelings`.