...
With the Prometheus operator running, we can create a service monitor that will watch the Rook cluster and collect metrics regularly. From the root of your locally cloned Rook repo, go the monitoring directorydirectory and make the following change to the service-monitor.yaml
file
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ cd # The path is "rook/cluster/examples/kubernetes/ceph/monitoring" # make the following change in the service-monitor.yaml fileapiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: rook-ceph-mgr namespace: rook-ceph labels: team: rook release: prometheus # <--- Insert the indicated label team: rook spec: namespaceSelector: matchNames: - rook-ceph # Save the file and create the component $ kubectl create -f service-monitor.yaml selector: matchLabels: app: rook-ceph-mgr rook_cluster: rook-ceph endpoints: - port: http-metrics path: /metrics interval: 5s |
Save the file and create the component. The release: prometheus
label that we have introduced serves so that the Prometheus operator can "see" the serviceMonitor. How do I find out which label is used by Prometheus? Try running a describe and look for the ServiceMonitorSelector parameter. The serviceMonitor, in turn, points to the components it wants to analyze thanks to the parameters namespaceSelector
and selector
.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$ kubectl describe prometheus -n monitoring Name: prometheus-kube-prometheus-prometheus Namespace: monitoring Labels: app=kube-prometheus-stack-prometheus app.kubernetes.io/managed-by=Helm chart=kube-prometheus-stack-13.5.0 heritage=Helm release=prometheus Annotations: meta.helm.sh/release-name: prometheus meta.helm.sh/release-namespace: monitoring API Version: monitoring.coreos.com/v1 Kind: Prometheus . . . Service Monitor Selector: Match Labels: Release: prometheus # <--- Pay attention!!! Shards: 1 Version: v2.24.0 Events: <none> |
The serviceMonitor, in turn, points to the components it wants to analyze thanks to the parameters
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
spec:
namespaceSelector:
matchNames:
- rook-ceph
selector:
matchLabels:
app: rook-ceph-mgr # <--- Pay attention!!!
rook_cluster: rook-ceph |
Once the Prometheus server is running, you can open a web browser and go http://<VM_FIP>:<Prometheus_port>
. You should see a new target.
...