...
Code Block |
---|
language | bash |
---|
title | Prometheus Instances |
---|
collapse | true |
---|
|
$ cd rook/cluster/examples/kubernetes/ceph/monitoring
# make the following change in the service-monitor.yaml file
metadata:
name: rook-ceph-mgr
namespace: rook-ceph
labels:
team: rook
release: prometheus # <--- Insert label
# Save the file and create the component
$ kubectl create -f service-monitor.yaml
$ kubectl create -f prometheus.yaml
$ kubectl create -f prometheus-service.yaml
# Ensure that the Prometheus server pod gets created and advances to the Running state before moving on
|
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
Code Block |
---|
language | bash |
---|
title | Describe Prometheus |
---|
collapse | true |
---|
|
$ 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 |
---|
language | yml |
---|
title | serviceMonitor selectors |
---|
collapse | true |
---|
|
spec:
namespaceSelector:
matchNames:
- rook-ceph
selector:
matchLabels:
app: rook-ceph-mgr # <--- Pay attention!!!
rook_cluster: rook-ceph$ kubectl -n rook-ceph get pod prometheus-rook-prometheus-0 |
Once the Prometheus server is running, you can open a web browser and go http://<VM_FIP>:<port>
.<Prometheus_port>
. You should see a new target.
Image Addedrook-ceph-mgr