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) <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-07-13 08:59:28 +03:00
parent b32272ef40
commit 44cfd16036
@@ -79,6 +79,9 @@ matrix_prometheus_services_connect_scraper_synapse_workers_static_configs_as_yam
labels: labels:
instance: {{ matrix_prometheus_services_connect_scraper_synapse_workers_static_configs_instance | to_json }} instance: {{ matrix_prometheus_services_connect_scraper_synapse_workers_static_configs_instance | to_json }}
worker_id: {{ worker.id | 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 }} job: {{ worker.type | to_json }}
app: {{ worker.app | to_json }} app: {{ worker.app | to_json }}
{% endif %} {% endif %}