apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: apiserver
  namespace: monitoring
  labels:
    app.kubernetes.io/part-of: osdc-monitoring
spec:
  # The "kubernetes" Service in the default namespace is the API server.
  namespaceSelector:
    matchNames:
      - default
  selector:
    matchLabels:
      component: apiserver
      provider: kubernetes
  endpoints:
    - port: https
      scheme: https
      interval: 60s
      bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
      tlsConfig:
        caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        serverName: kubernetes
        insecureSkipVerify: false
      metricRelabelings:
        # Keep only essential API server health metrics, drop everything else
        - action: keep
          sourceLabels: [__name__]
          regex: "apiserver_request_total|apiserver_request_terminations_total"
