You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 2
Next »
After installing Prometheus, by connecting to its dashboard, you will notice a list of services already under monitoring: these are useful resources for the functioning of Prometheus itself (e.g. alertmanager, Grafana) or typical of each K8s cluster (apiserver, controller-manager, scheduler ). But how do you monitor an application in general? As an example, let's try to monitor Longhorn, a distributed block storage system for Kubernetes.
ServiceMonitor
The heart of everything are the service monitors, an intermediate layer between the application to be monitored and the Prometheus operator. Within this component it is necessary to indicate which are the "coordinates" of the K8s service associated with the application. In our case we are interested in the longhorn-backend service. Let's try to print some information about it
$ k get svc -n longhorn-system --show-labels
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE LABELS
csi-attacher ClusterIP 10.233.13.82 <none> 12345/TCP 24h app=csi-attacher,longhorn.io/managed-by=longhorn-manager
csi-provisioner ClusterIP 10.233.62.177 <none> 12345/TCP 24h app=csi-provisioner,longhorn.io/managed-by=longhorn-manager
csi-resizer ClusterIP 10.233.40.134 <none> 12345/TCP 24h app=csi-resizer,longhorn.io/managed-by=longhorn-manager
csi-snapshotter ClusterIP 10.233.19.24 <none> 12345/TCP 24h app=csi-snapshotter,longhorn.io/managed-by=longhorn-manager
longhorn-backend ClusterIP 10.233.19.4 <none> 9500/TCP 24h app.kubernetes.io/instance=longhorn,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=longhorn,app.kubernetes.io/version=v1.1.2,app=longhorn-manager,helm.sh/chart=longhorn-1.1.2
longhorn-frontend ClusterIP 10.233.62.6 <none> 80/TCP 24h app.kubernetes.io/instance=longhorn,app.kubernetes.io/managed-by=Helm,app.kubernetes.io/name=longhorn,app.kubernetes.io/version=v1.1.2,app=longhorn-ui,helm.sh/chart=longhorn-1.1.2