Skip to content

ServiceMonitor with using https and TLS

Back

This example show a basic configuration for ServiceMonitor.

spec:
  endpoints:
  - interval: 30s
    port: metrics
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client-ca.crt
      certFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.crt
      keyFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.key
      serverName: ""
  jobLabel: k8s-app
  namespaceSelector:
    matchNames:
    - kube-system
  selector:
    matchLabels:
      k8s-app: etcd

It means that Prometheus 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: etcd
  • metrics will collect from all discovered pod from port with name metrics with interval 30s and schema https
  • metrics will collect with TLS config and specified certificates
  • for verify certificates will use name "" (specify in serverName: "")

Files

How to apply example

Kubernetes:

kubectl apply -f service-monitor-etcd.yaml

OpenShift:

oc apply -f service-monitor-etcd.yaml

Prometheus operator API

Victoriametrics operator API