# Configure cluster-monitoring for cluster-authentication-operator
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: authentication-operator
  namespace: openshift-authentication-operator
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    metricRelabelings:
    - action: drop
      regex: etcd_(debugging|disk|request|server).*
      sourceLabels:
      - __name__
    path: /metrics
    port: https
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: metrics.openshift-authentication-operator.svc
  jobLabel: component
  selector:
    matchLabels:
      app: authentication-operator
---
# Configure cluster-monitoring for cluster authentication resources
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: oauth-openshift
  namespace: openshift-authentication
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    metricRelabelings:
    - action: drop
      regex: etcd_(debugging|disk|request|server).*
      sourceLabels:
      - __name__
    path: /metrics
    port: https
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: oauth-openshift.openshift-authentication.svc
  jobLabel: component
  selector:
    matchLabels:
      app: oauth-openshift
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: openshift-oauth-apiserver
  namespace: openshift-oauth-apiserver
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    metricRelabelings:
    - action: drop
      regex: etcd_(debugging|disk|server).*
      sourceLabels:
      - __name__
    - action: drop
      regex: apiserver_admission_controller_admission_latencies_seconds_.*
      sourceLabels:
      - __name__
    - action: drop
      regex: apiserver_admission_step_admission_latencies_seconds_.*
      sourceLabels:
      - __name__
    - action: drop
      regex: apiserver_request_duration_seconds_bucket;(0.15|0.25|0.3|0.35|0.4|0.45|0.6|0.7|0.8|0.9|1.25|1.5|1.75|2.5|3|3.5|4.5|6|7|8|9|15|25|30|50)
      sourceLabels:
      - __name__
      - le
    relabelings:
    - action: replace
      targetLabel: apiserver
      replacement: openshift-oauth-apiserver
    port: https
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: api.openshift-oauth-apiserver.svc
  namespaceSelector:
    matchNames:
    - openshift-oauth-apiserver
  selector:
    matchLabels:
      app: openshift-oauth-apiserver
