Monitoring Ceph-CSI metrics with Prometheus Operator¶
The CSI sidecar containers (csi-provisioner, csi-attacher, csi-resizer
and csi-snapshotter) deployed with the Ceph-CSI controller plugin pods can
expose Prometheus metrics through an HTTP endpoint. A PodMonitor resource
tells the Prometheus Operator how to
discover and scrape those metrics.
Note: the
liveness-prometheussidecar is deprecated and is not used by the approach documented here. Node plugin pods expose no CSI metrics endpoints, so node plugin monitoring is out of scope.
Prerequisites¶
- The Prometheus Operator is installed in the cluster, so that the
monitoring.coreos.com/v1API (with thePodMonitorkind) is served. - A
Prometheus(orPrometheusAgent) resource that selects thePodMonitorobjects, e.g.:
Adjust the PodMonitor labels in the example to match the selector of
your Prometheus deployment.
Admin Responsibilities¶
- Enable the metrics endpoint of the CSI sidecars on the
DriverCR, throughcontrollerPlugin.containerExtraArgs(one port per sidecar; the--http-endpointargument must carry a value, otherwise no metrics server is started):
spec:
controllerPlugin:
containerExtraArgs:
csi-provisioner: ["--http-endpoint=:8080"]
csi-attacher: ["--http-endpoint=:8081"]
csi-resizer: ["--http-endpoint=:8082"]
csi-snapshotter: ["--http-endpoint=:8083"]
- Apply the example
PodMonitor:
The example
scrapes the controller plugin pods of the rbd.csi.ceph.com driver in the
ceph-csi-driver namespace. Adjust metadata.namespace, the app label
in spec.selector and the port numbers to your deployment.
- Deploy as many
PodMonitorresources as you have drivers. The manifest is the same for every driver, so create one more copy of the example for each additional driver and adjust only these driver-specific fields:
| Field | RBD (the example) | CephFS | NFS | NVMe-oF |
|---|---|---|---|---|
metadata.name |
rbd-controller-podmonitor |
cephfs-controller-podmonitor |
nfs-controller-podmonitor |
nvmeof-controller-podmonitor |
spec.selector.matchLabels.app |
rbd.csi.ceph.com-ctrlplugin |
cephfs.csi.ceph.com-ctrlplugin |
nfs.csi.ceph.com-ctrlplugin |
nvmeof.csi.ceph.com-ctrlplugin |
podMetricsEndpoints[].targetPort |
8080-8083 |
8090-8093 |
8100-8103 |
8110-8113 |
Each driver needs its own set of ports: with hostNetwork: true, the
ports bind on the node itself, so two controller plugin pods scheduled on
the same node cannot bind the same port. Enable the matching
--http-endpoint ports in that driver's containerExtraArgs.
- Alternatively, ship the
PodMonitorresources with your Helm release through theceph-csi-driverschartextraDeployvalue, which renders arbitrary resources throughtpl:
extraDeploy:
- apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: rbd-controller-podmonitor
namespace: {{ .Release.Namespace }}
labels:
monitoring: ceph-csi
spec:
selector:
matchLabels:
app: rbd.csi.ceph.com-ctrlplugin
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
podMetricsEndpoints:
- targetPort: 8080
path: /metrics
interval: 30s
Ceph-CSI Operator Responsibilities¶
The operator does not create or manage PodMonitor resources. It renders the
controllerPlugin.containerExtraArgs configured on the Driver CR into the
sidecar container arguments, which is what makes the metrics endpoints (the
targets of the PodMonitor above) available.