Home > Software design >  How can I disable a service been monitor on the prometheus-operator stack
How can I disable a service been monitor on the prometheus-operator stack

Time:11-09

We have deployed the prometheus-operator stack on AWS EKS

By default it monitors all services deployed.

Is it possible to configure the prometheus-operator stack to by default monitor all services with the exceptions of services "foo" and "bar"

CodePudding user response:

you can use service monitor resource to limit what to be monitored: take a look at documentation

you can remove services from monitoring by excluding them from selector or namespace selector in serviceMonitor specification.

as an example:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: k8s-apps-http
  labels:
    k8s-apps: http
spec:
  jobLabel: k8s-app
  selector:
    matchExpressions:
    - {key: foo, operator: NotIn} <---
    - {key: bar, operator: NotIn} <---
  namespaceSelector:
    matchNames:
    - kube-system
    - monitoring
  endpoints:
  - port: http-metrics
    interval: 15s
  • Related