Prometheus Operator Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 3: Line 3:
=Overview=
=Overview=
The Operator decouples the deployment of Prometheus instances from the configuration of which [[Prometheus_Concepts#Target|targets]] they are monitoring. The Operator defines two custom resources: [[#Prometheus|Prometheus]] and [[#ServiceMonitor|ServiceMonitor]].
The Operator decouples the deployment of Prometheus instances from the configuration of which [[Prometheus_Concepts#Target|targets]] they are monitoring. The Operator defines two custom resources: [[#Prometheus|Prometheus]] and [[#ServiceMonitor|ServiceMonitor]].
The Operator ensures that for each [[#Prometheus|Prometheus]] resource there is a set of Prometheus servers that are running with the correct configuration. The operator manages the servers' configuration, including persistent volume claims, number of replicas, the server version, the Alertmanager instances, the monitoring targets and their associated parameters.
The monitoring targets and their parameters can be set manually, but the preferred option is to let the Operator generate the configuration based on declared [[#ServiceMonitor|ServiceMonitor]] instances.


[[File: PrometheusOperator.png]]
[[File: PrometheusOperator.png]]

Revision as of 22:36, 14 October 2020

Internal

Overview

The Operator decouples the deployment of Prometheus instances from the configuration of which targets they are monitoring. The Operator defines two custom resources: Prometheus and ServiceMonitor.

The Operator ensures that for each Prometheus resource there is a set of Prometheus servers that are running with the correct configuration. The operator manages the servers' configuration, including persistent volume claims, number of replicas, the server version, the Alertmanager instances, the monitoring targets and their associated parameters.

The monitoring targets and their parameters can be set manually, but the preferred option is to let the Operator generate the configuration based on declared ServiceMonitor instances.

PrometheusOperator.png

Custom Resources

Prometheus Resource

The Prometheus resource declares a "serviceMonitorSelector":

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
...
spec:
  serviceMonitorSelector:
    matchLabels:
      release: prometheus

ServiceMonitor Resource

A ServiceMonitor is a custom resource


The labels are important, they must match Prometheus serviceMonitorSelector.

The current service monitor list can be obtained with:

kubectl -n <namespace> get servicemonitors

Configuring Prometheus with Prometheus Operator

Configuring Prometheus with Prometheus Operator