Skip to content

Commit d0c84ad

Browse files
authored
fix: use safe default values for servicemonitor (#113)
1 parent eeb1dce commit d0c84ad

3 files changed

Lines changed: 55 additions & 24 deletions

File tree

charts/kamaji-etcd/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,16 @@ Here the values you can override:
100100
| serviceAccount.name | string | `""` | Define the ServiceAccount name to use during the setup and provision of the etcd backing storage (default: "") |
101101
| serviceMonitor.annotations | object | `{}` | Assign additional Annotations |
102102
| serviceMonitor.enabled | bool | `false` | Enable ServiceMonitor for Prometheus |
103-
| serviceMonitor.endpoint | object | `{"interval":"15s","metricRelabelings":[],"relabelings":[],"scrapeTimeout":""}` | ServiceAccount for scraping metrics from etcd serviceAccount: # -- ServiceAccount name name: prometheus # -- ServiceAccount namespace namespace: monitoring-system |
104103
| serviceMonitor.endpoint.interval | string | `"15s"` | Set the scrape interval for the endpoint of the serviceMonitor |
105104
| serviceMonitor.endpoint.metricRelabelings | list | `[]` | Set metricRelabelings for the endpoint of the serviceMonitor |
106105
| serviceMonitor.endpoint.relabelings | list | `[]` | Set relabelings for the endpoint of the serviceMonitor |
107106
| serviceMonitor.endpoint.scrapeTimeout | string | `""` | Set the scrape timeout for the endpoint of the serviceMonitor |
108-
| serviceMonitor.labels | object | `{}` | Assign additional labels according to Prometheus' serviceMonitorSelector matching labels |
109-
| serviceMonitor.matchLabels | object | `{}` | Change matching labels |
110-
| serviceMonitor.namespace | string | `""` | Install the ServiceMonitor into a different Namespace, as the monitoring stack one (default: the release one) |
107+
| serviceMonitor.labels | object | `{"release":"kube-prometheus-stack"}` | Assign additional labels according to Prometheus' serviceMonitorSelector matching labels. By default, it uses the kube-prometheus-stack one. |
108+
| serviceMonitor.matchLabels | object | `{}` | Change matching labels. By default, it uses client service labels. |
109+
| serviceMonitor.namespace | string | `""` | Install the ServiceMonitor into a different namespace than release one. |
110+
| serviceMonitor.serviceAccount | object | `{"name":"kube-prometheus-stack-prometheus","namespace":"monitoring-system"}` | ServiceAccount for scraping metrics from etcd. By defult, it uses the kube-prometheus-stack one. |
111+
| serviceMonitor.serviceAccount.name | string | `"kube-prometheus-stack-prometheus"` | ServiceAccount name |
112+
| serviceMonitor.serviceAccount.namespace | string | `"monitoring-system"` | ServiceAccount namespace |
111113
| serviceMonitor.targetLabels | list | `[]` | Set targetLabels for the serviceMonitor |
112114
| snapshotCount | string | `"10000"` | Number of committed transactions to trigger a snapshot to disk. |
113115
| tolerations | list | `[]` | Kubernetes node taints that the etcd pods would tolerate |

charts/kamaji-etcd/values.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,23 @@ datastore:
137137
serviceMonitor:
138138
# -- Enable ServiceMonitor for Prometheus
139139
enabled: false
140-
# -- Install the ServiceMonitor into a different Namespace, as the monitoring stack one (default: the release one)
140+
# -- Install the ServiceMonitor into a different namespace than release one.
141141
namespace: ''
142-
# -- Assign additional labels according to Prometheus' serviceMonitorSelector matching labels
143-
labels: {}
142+
# -- Assign additional labels according to Prometheus' serviceMonitorSelector matching labels. By default, it uses the kube-prometheus-stack one.
143+
labels:
144+
release: kube-prometheus-stack
144145
# -- Assign additional Annotations
145146
annotations: {}
146-
# -- Change matching labels
147+
# -- Change matching labels. By default, it uses client service labels.
147148
matchLabels: {}
148149
# -- Set targetLabels for the serviceMonitor
149150
targetLabels: []
150-
# -- ServiceAccount for scraping metrics from etcd
151-
# serviceAccount:
152-
# # -- ServiceAccount name
153-
# name: prometheus
154-
# # -- ServiceAccount namespace
155-
# namespace: monitoring-system
151+
# -- ServiceAccount for scraping metrics from etcd. By defult, it uses the kube-prometheus-stack one.
152+
serviceAccount:
153+
# -- ServiceAccount name
154+
name: kube-prometheus-stack-prometheus
155+
# -- ServiceAccount namespace
156+
namespace: monitoring-system
156157
endpoint:
157158
# -- Set the scrape interval for the endpoint of the serviceMonitor
158159
interval: "15s"

docs/monitoring.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,60 @@ spec:
1616
...
1717
```
1818

19-
These metrics can be collected by Prometheus and used for both monitoring and debugging purposes.
19+
The `etcd` metrics are exposed on port `2381` by default, and can be accessed via the `/metrics` endpoint of kamaji-etcd-client service:
2020

21-
## Setting up Prometheus
21+
```yaml
22+
apiVersion: v1
23+
kind: Service
24+
metadata:
25+
labels:
26+
prometheus.io/metrics: "true"
27+
name: kamaji-etcd-client
28+
spec:
29+
ports:
30+
- name: client
31+
port: 2379
32+
protocol: TCP
33+
targetPort: 2379
34+
- name: metrics
35+
port: 2381
36+
protocol: TCP
37+
targetPort: 2381
38+
selector:
39+
app.kubernetes.io/instance: kamaji-etcd
40+
```
41+
42+
These metrics can be collected by Prometheus Operator and used for both monitoring and debugging purposes.
2243
23-
To begin monitoring `kamaji-etcd`, install the Prometheus stack using Helm:
44+
## Setting up Prometheus Operator
45+
46+
To begin monitoring `kamaji-etcd`, install the Prometheus Operator stack using Helm:
2447

2548
```sh
26-
helm repo add bitnami https://charts.bitnami.com/bitnami
49+
helm repo add kube-prometheus-stack https://prometheus-community.github.io/helm-charts
2750
helm repo update
28-
helm install kube-prometheus bitnami/kube-prometheus \
51+
helm install kube-prometheus kube-prometheus-stack/kube-prometheus-stack \
2952
--set prometheus.persistence.enabled=true \
3053
--namespace monitoring-system \
3154
--create-namespace
3255
```
3356

34-
The `kamaji-etcd` Helm chart includes an optional `ServiceMonitor` for Prometheus, enabling it to scrape `etcd` metrics:
57+
The `kamaji-etcd` Helm chart includes an optional `ServiceMonitor` for Prometheus Operator, enabling it to scrape `etcd` metrics:
3558

3659
```sh
3760
helm -n kamaji-etcd upgrade kamaji-etcd clastix/kamaji-etcd \
3861
--set datastore.enabled=true \
3962
--set datastore.name=default \
40-
--set fullnameOverride=default \
41-
--set serviceMonitor.enabled=true \
42-
--set serviceMonitor.namespace=monitoring-system
63+
--set fullnameOverride=kamaji-etcd \
64+
--set serviceMonitor.enabled=true
4365
```
4466

67+
By default such `ServiceMonitor` is installed in the same namespace as the `kamaji-etcd` release. If you want to install it in a different namespace, you can set the `serviceMonitor.namespace` value to the desired namespace.
68+
69+
By default, the `ServiceMonitor` is configured to scrape metrics every 15 seconds. You can adjust this interval by setting the `serviceMonitor.endpoint.interval` value.
70+
71+
By default, the `ServiceMonitor` uses the ServiceAccount `kube-prometheus-stack-prometheus` in the `monitoring-system` namespace to scrape metrics from etcd. If you want to use a different ServiceAccount, you can set the `serviceMonitor.serviceAccount.name` and value `serviceMonitor.serviceAccount.namespace` to the desired values.
72+
4573
## Key Metrics to Monitor
4674

4775
Here’s a summary of important `etcd` metrics that help monitor cluster health. A full list of metrics is available [here](https://etcd.io/docs/v3.5/metrics/etcd-metrics-latest.txt).
@@ -97,7 +125,7 @@ max(rate(etcd_server_proposals_failed_total[60m]))
97125
High disk write latency can signal disk issues and affect `etcd` stability. To monitor disk performance, visualize the time taken to commit 99% of requests:
98126

99127
```sh
100-
histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket{job=~"etcd"}[5m])) by (le,instance))
128+
histogram_quantile(0.99, sum(rate(etcd_disk_backend_commit_duration_seconds_bucket{job=~"kamaji-etcd"}[5m])) by (le,instance))
101129
```
102130

103131
### Network Metrics

0 commit comments

Comments
 (0)