Skip to content

Commit a6437d3

Browse files
Merge pull request #3074 from czeslavo/prom-operator-is-dependency-1.19
[v1.19] Document handling multiple clusters in a single Prometheus
2 parents a0b04f7 + a00ae60 commit a6437d3

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

docs/source/management/monitoring/setup.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,37 @@ You also need to ensure that your `Prometheus` instance is configured to discove
106106
:end-before: "# [/selectors]"
107107
:::
108108

109-
:::{note}
110-
If you leave selectors empty, Prometheus will select all `ServiceMonitor` and `PrometheusRule` resources. It may be desirable in some cases.
111-
Please refer to the [Prometheus Operator documentation](https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.PrometheusSpec)
112-
for more details on how to configure `serviceMonitorSelector` and `ruleSelector`.
109+
#### Monitoring multiple ScyllaClusters with a single Prometheus
110+
111+
If you have more than one `ScyllaCluster` in your Kubernetes cluster, and you want to monitor all of them using the same `Prometheus` instance,
112+
you can customize the selectors to match `ServiceMonitors` and `PrometheusRules` created for multiple `ScyllaClusters`.
113+
114+
Assuming you're going to create two `ScyllaDBMonitoring` objects named `cluster-1-monitoring` and `cluster-2-monitoring`
115+
for two different `ScyllaClusters` in two distinct namespaces, you can set the selectors like this so that the `Prometheus` instance
116+
will scrape both of them:
117+
118+
:::{literalinclude} ../../../../examples/monitoring/v1alpha1/multi-cluster.prometheus.yaml
119+
:language: yaml
120+
:dedent:
121+
:start-after: "# [selectors]"
122+
:end-before: "# [/selectors]"
123+
:::
124+
125+
In this case, we're setting `serviceMonitorNamespaceSelector` and `ruleNamespaceSelector` to an empty selector, which means that `Prometheus`
126+
will look for `ServiceMonitors` and `PrometheusRules` in all namespaces.
127+
128+
:::{warning}
129+
If you want to monitor multiple `ScyllaClusters` using a single `Prometheus` instance, ensure all selected `ScyllaClusters`
130+
have unique names across the entire Kubernetes cluster (not just within their namespaces).
131+
Our monitoring setup cannot currently distinguish metrics collected from `ScyllaClusters` with colliding names, even if
132+
they are in different namespaces.
113133
:::
114134

135+
Please refer to the [Prometheus Operator documentation](https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.PrometheusSpec)
136+
for more details on how to configure selectors in the `Prometheus` specification.
137+
138+
#### Deploy Prometheus
139+
115140
You can deploy a `Prometheus` instance by executing the following command:
116141

117142
:::{code-block} shell
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This Prometheus configuration is intended to be used in conjunction with multiple ScyllaDBMonitoring
2+
# instances configured to use the "External" Prometheus mode.
3+
apiVersion: monitoring.coreos.com/v1
4+
kind: Prometheus
5+
metadata:
6+
name: prometheus
7+
# [names]
8+
spec:
9+
serviceAccountName: "prometheus"
10+
serviceName: "prometheus"
11+
# [/names]
12+
version: "v3.5.0"
13+
securityContext:
14+
runAsNonRoot: true
15+
runAsUser: 65534
16+
fsGroup: 65534
17+
web:
18+
pageTitle: "ScyllaDB Prometheus"
19+
# [selectors]
20+
serviceMonitorNamespaceSelector: {} # Select ServiceMonitors in all namespaces.
21+
serviceMonitorSelector: # Select ServiceMonitors created by multiple ScyllaDBMonitoring instances.
22+
matchExpressions:
23+
- key: scylla-operator.scylladb.com/scylladbmonitoring-name
24+
operator: In
25+
values:
26+
- "cluster-1-monitoring"
27+
- "cluster-2-monitoring"
28+
ruleNamespaceSelector: {} # Select Rules in all namespaces.
29+
ruleSelector: # Select Rules created by multiple ScyllaDBMonitoring instances.
30+
matchExpressions:
31+
- key: scylla-operator.scylladb.com/scylladbmonitoring-name
32+
operator: In
33+
values:
34+
- "cluster-1-monitoring"
35+
- "cluster-2-monitoring"
36+
# [/selectors]
37+
alerting:
38+
alertmanagers:
39+
- name: "scylla-monitoring"
40+
port: web

0 commit comments

Comments
 (0)