Skip to content

Commit c22125b

Browse files
committed
Document the scraper binding and let the ServiceMonitor carry labels
metrics.serviceMonitor.labels adds labels to the ServiceMonitor for a Prometheus serviceMonitorSelector. The values and the README spell out the ClusterRoleBinding a scraper's ServiceAccount needs, which the chart cannot create, and the README names claims as the billable unit. Assisted-By: LLM Signed-off-by: Timofei Larkin <[email protected]>
1 parent 1670714 commit c22125b

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,33 @@ by the release workflow on every push to main.
130130
With `metrics.enabled`, the controller serves metrics over HTTPS on port
131131
8443 behind the Service `address-controller-metrics`. Scrapes are
132132
authenticated and authorized against the API server, so the scraper's
133-
identity needs the `address-controller-metrics-reader` ClusterRole. Besides
134-
the controller-runtime metrics, two gauges count the ledger:
133+
identity needs the `address-controller-metrics-reader` ClusterRole, for
134+
example:
135+
136+
```sh
137+
kubectl create clusterrolebinding prometheus-address-controller-metrics \
138+
--clusterrole=address-controller-metrics-reader \
139+
--serviceaccount=<prometheus-namespace>:<prometheus-serviceaccount>
140+
```
141+
142+
Besides the controller-runtime metrics, two gauges count the ledger:
135143

136144
| metric | labels |
137145
|---|---|
138146
| `address_controller_ipaddresses` | `class`, `phase` |
139147
| `address_controller_ipaddressclaims` | `namespace`, `class` (resolved), `phase` |
140148

149+
Claims are the billable unit, as `PersistentVolumeClaim`s are for storage: a
150+
claim holds its addresses whether or not a Service uses them, so
151+
`address_controller_ipaddressclaims{phase="Bound"}` counts what each
152+
namespace holds.
153+
141154
`metrics.serviceMonitor.enabled` and `metrics.prometheusRule.enabled` add a
142155
`ServiceMonitor` and alerts where the `monitoring.coreos.com` API exists:
143156
addresses in `Conflict` or `Lost` for 5 minutes, and claims `Pending` for
144-
15 minutes.
157+
15 minutes. `metrics.serviceMonitor.labels` adds labels to the
158+
`ServiceMonitor`, for a Prometheus `serviceMonitorSelector`.
159+
145160
## Development
146161

147162
```sh

‎chart/address-controller/templates/metrics.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ metadata:
6565
namespace: {{ .Release.Namespace }}
6666
labels:
6767
{{- include "address-controller.labels" . | nindent 4 }}
68+
{{- with .Values.metrics.serviceMonitor.labels }}
69+
{{- toYaml . | nindent 4 }}
70+
{{- end }}
6871
spec:
6972
selector:
7073
matchLabels:

‎chart/address-controller/values.yaml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ metrics:
2929
enabled: false
3030
serviceMonitor:
3131
# A monitoring.coreos.com ServiceMonitor for the Service; rendered only
32-
# where that API exists.
32+
# where that API exists. The scraping Prometheus's ServiceAccount still
33+
# needs a ClusterRoleBinding to address-controller-metrics-reader, which
34+
# the chart cannot create without knowing that ServiceAccount.
3335
enabled: false
36+
# Extra labels on the ServiceMonitor, e.g. to match a Prometheus
37+
# serviceMonitorSelector.
38+
labels: {}
3439
prometheusRule:
3540
# Alerts on Conflict and Lost addresses and on long-Pending claims;
3641
# rendered only where monitoring.coreos.com exists.

0 commit comments

Comments
 (0)