From 44cfd1603685122176425b97fc587dac7457f4c2 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 13 Jul 2026 08:59:28 +0300 Subject: [PATCH] Add index label to Synapse worker Prometheus targets The upstream Synapse Grafana dashboard uses `{{job}}-{{index}}` in its legends to tell workers apart, but the worker scrape configs only set instance, worker_id, job and app labels. Without an index label, the dashboard legends collapsed and workers could not be distinguished. Derive the index label from the worker id (its per-type index is the first number in the id, e.g. federation-sender-1, stream-writer-2-events), matching the index label already set on the main process target. Fixes #2158 Fixes #2159 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../matrix-prometheus-services-connect/defaults/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/custom/matrix-prometheus-services-connect/defaults/main.yml b/roles/custom/matrix-prometheus-services-connect/defaults/main.yml index ccbaefdb8..339dca475 100644 --- a/roles/custom/matrix-prometheus-services-connect/defaults/main.yml +++ b/roles/custom/matrix-prometheus-services-connect/defaults/main.yml @@ -79,6 +79,9 @@ matrix_prometheus_services_connect_scraper_synapse_workers_static_configs_as_yam labels: instance: {{ matrix_prometheus_services_connect_scraper_synapse_workers_static_configs_instance | to_json }} worker_id: {{ worker.id | to_json }} + {# The only number in a worker id is its per-type index (e.g. federation-sender-1, stream-writer-2-events). #} + {# The upstream Synapse Grafana dashboard uses job and index labels in its legends to tell workers apart. #} + index: {{ worker.id | regex_search('[0-9]+') }} job: {{ worker.type | to_json }} app: {{ worker.app | to_json }} {% endif %}