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

Improve documentation how to configure prometheus for workers #8822

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8822.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve documentation how to configure prometheus for workers.
10 changes: 7 additions & 3 deletions contrib/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Add a new job to the main prometheus.conf file:
```

### for Prometheus v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(aside: I wonder if we should get rid of the "prometheus v1" section, since it's unmaintained and nobody should be using it)


Add a new job to the main prometheus.yml file:

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

static_configs:
- targets: ['SERVER.LOCATION:PORT']
- targets: ["my.server.here:port"]
```

An example of a Prometheus configuration with workers can be found in
[metrics-howto.md](https://github.com/matrix-org/synapse/blob/master/docs/metrics-howto.md).

To use `synapse.rules` add

```yaml
rule_files:
- "/PATH/TO/synapse-v2.rules"
rule_files:
- "/PATH/TO/synapse-v2.rules"
```

Metrics are disabled by default when running synapse; they must be enabled
Expand Down
74 changes: 57 additions & 17 deletions docs/metrics-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
can be enabled by adding the \"metrics\" resource to the existing
listener as such:

resources:
- names:
- client
- metrics
```yaml
resources:
- names:
- client
- metrics
```

This provides a simple way of adding metrics to your Synapse
installation, and serves under `/_synapse/metrics`. If you do not
Expand All @@ -31,11 +33,13 @@

Add a new listener to homeserver.yaml:

listeners:
- type: metrics
port: 9000
bind_addresses:
- '0.0.0.0'
```yaml
listeners:
- type: metrics
port: 9000
bind_addresses:
- '0.0.0.0'
```

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

- job_name: "synapse"
metrics_path: "/_synapse/metrics"
static_configs:
- targets: ["my.server.here:port"]
```yaml
- job_name: "synapse"
scrape_interval: 15s
metrics_path: "/_synapse/metrics"
static_configs:
- targets: ["my.server.here:port"]
```

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

1. Restart Prometheus.

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/)
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/)

## Monitoring workers

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

```yaml
- type: metrics
bind_address: ''
port: 9101
- type: metrics
bind_address: ''
port: 9101
```

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

Example Prometheus target for Synapse with workers:

```yaml
- job_name: "synapse"
scrape_interval: 15s
metrics_path: "/_synapse/metrics"
static_configs:
- targets: ["my.server.here:port"]
labels:
instance: "my.server"
job: "master"
index: 1
- targets: ["my.workerserver.here:port"]
labels:
instance: "my.server"
job: "generic_worker"
index: 1
- targets: ["my.workerserver.here:port"]
labels:
instance: "my.server"
job: "generic_worker"
index: 2
- targets: ["my.workerserver.here:port"]
labels:
instance: "my.server"
job: "media_repository"
index: 1
```

Labels (`instance`, `job`, `index`) can be defined as anything.
The labels are used to group graphs in grafana.

## Renaming of metrics & deprecation of old names in 1.2

Synapse 1.2 updates the Prometheus metrics to match the naming
Expand Down