Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 14f81a6

Browse files
authored
Improve documentation how to configure prometheus for workers (#8822)
1 parent 3f0ff53 commit 14f81a6

File tree

3 files changed

+65
-20
lines changed

3 files changed

+65
-20
lines changed

changelog.d/8822.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve documentation how to configure prometheus for workers.

contrib/prometheus/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Add a new job to the main prometheus.conf file:
2020
```
2121

2222
### for Prometheus v2
23+
2324
Add a new job to the main prometheus.yml file:
2425

2526
```yaml
@@ -29,14 +30,17 @@ Add a new job to the main prometheus.yml file:
2930
scheme: "https"
3031

3132
static_configs:
32-
- targets: ['SERVER.LOCATION:PORT']
33+
- targets: ["my.server.here:port"]
3334
```
3435
36+
An example of a Prometheus configuration with workers can be found in
37+
[metrics-howto.md](https://github.com/matrix-org/synapse/blob/master/docs/metrics-howto.md).
38+
3539
To use `synapse.rules` add
3640

3741
```yaml
38-
rule_files:
39-
- "/PATH/TO/synapse-v2.rules"
42+
rule_files:
43+
- "/PATH/TO/synapse-v2.rules"
4044
```
4145

4246
Metrics are disabled by default when running synapse; they must be enabled

docs/metrics-howto.md

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
can be enabled by adding the \"metrics\" resource to the existing
1414
listener as such:
1515

16-
resources:
17-
- names:
18-
- client
19-
- metrics
16+
```yaml
17+
resources:
18+
- names:
19+
- client
20+
- metrics
21+
```
2022
2123
This provides a simple way of adding metrics to your Synapse
2224
installation, and serves under `/_synapse/metrics`. If you do not
@@ -31,11 +33,13 @@
3133

3234
Add a new listener to homeserver.yaml:
3335

34-
listeners:
35-
- type: metrics
36-
port: 9000
37-
bind_addresses:
38-
- '0.0.0.0'
36+
```yaml
37+
listeners:
38+
- type: metrics
39+
port: 9000
40+
bind_addresses:
41+
- '0.0.0.0'
42+
```
3943

4044
For both options, you will need to ensure that `enable_metrics` is
4145
set to `True`.
@@ -47,10 +51,13 @@
4751
It needs to set the `metrics_path` to a non-default value (under
4852
`scrape_configs`):
4953

50-
- job_name: "synapse"
51-
metrics_path: "/_synapse/metrics"
52-
static_configs:
53-
- targets: ["my.server.here:port"]
54+
```yaml
55+
- job_name: "synapse"
56+
scrape_interval: 15s
57+
metrics_path: "/_synapse/metrics"
58+
static_configs:
59+
- targets: ["my.server.here:port"]
60+
```
5461

5562
where `my.server.here` is the IP address of Synapse, and `port` is
5663
the listener port configured with the `metrics` resource.
@@ -60,7 +67,8 @@
6067

6168
1. Restart Prometheus.
6269

63-
1. Consider using the [grafana dashboard](https://github.com/matrix-org/synapse/tree/master/contrib/grafana/) and required [recording rules](https://github.com/matrix-org/synapse/tree/master/contrib/prometheus/)
70+
1. Consider using the [grafana dashboard](https://github.com/matrix-org/synapse/tree/master/contrib/grafana/)
71+
and required [recording rules](https://github.com/matrix-org/synapse/tree/master/contrib/prometheus/)
6472

6573
## Monitoring workers
6674

@@ -76,9 +84,9 @@ To allow collecting metrics from a worker, you need to add a
7684
under `worker_listeners`:
7785

7886
```yaml
79-
- type: metrics
80-
bind_address: ''
81-
port: 9101
87+
- type: metrics
88+
bind_address: ''
89+
port: 9101
8290
```
8391

8492
The `bind_address` and `port` parameters should be set so that
@@ -87,6 +95,38 @@ don't clash with an existing worker.
8795
With this example, the worker's metrics would then be available
8896
on `http://127.0.0.1:9101`.
8997

98+
Example Prometheus target for Synapse with workers:
99+
100+
```yaml
101+
- job_name: "synapse"
102+
scrape_interval: 15s
103+
metrics_path: "/_synapse/metrics"
104+
static_configs:
105+
- targets: ["my.server.here:port"]
106+
labels:
107+
instance: "my.server"
108+
job: "master"
109+
index: 1
110+
- targets: ["my.workerserver.here:port"]
111+
labels:
112+
instance: "my.server"
113+
job: "generic_worker"
114+
index: 1
115+
- targets: ["my.workerserver.here:port"]
116+
labels:
117+
instance: "my.server"
118+
job: "generic_worker"
119+
index: 2
120+
- targets: ["my.workerserver.here:port"]
121+
labels:
122+
instance: "my.server"
123+
job: "media_repository"
124+
index: 1
125+
```
126+
127+
Labels (`instance`, `job`, `index`) can be defined as anything.
128+
The labels are used to group graphs in grafana.
129+
90130
## Renaming of metrics & deprecation of old names in 1.2
91131

92132
Synapse 1.2 updates the Prometheus metrics to match the naming

0 commit comments

Comments
 (0)