Skip to content

Simple ServiceMonitor

Back

This example show a basic configuration for ServiceMonitor.

spec:
  endpoints:
  - interval: 30s
    port: http
  jobLabel: k8s-app
  selector:
    matchLabels:
      k8s-app: sample-service

It means that Prometheus/Victoriametrics will collect metrics from service with settings:

  • metrics will collect with job with label k8s-app
  • metrics will collect from all pods with label k8s-app: sample-service
  • metrics will collect from all discovered pod from port with name http with interval 30s

Files

How to apply example

Kubernetes:

kubectl apply -f service-monitor.yaml

OpenShift:

oc apply -f service-monitor.yaml

Prometheus operator API

Victoriametrics operator API