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 As an example, let's try to monitor Longhorn, a distributed block storage system for Kubernetes.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: longhorn-prometheus-servicemonitor namespace: monitoring labels: release: mon spec: selector: matchLabels: app: longhorn-manager namespaceSelector: matchNames: - longhorn-system endpoints: - port: manager |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# This is just an excerpt from the output of the "describe" command $ kkubectl get prometheusdescribe -n monitoring -oyamlprometheus spec: Service serviceMonitorSelectorMonitor Selector: Match matchLabelsLabels: releaseRelease: mon |
After a few seconds, connecting to the Target list of the Prometheus dashboard, you will notice a new line. Of course, you will have Longhorn Metrics for Monitoring available to keep your application under control at all times.
...