---
# Source: olm/templates/0000_50_olm_19-service-monitor.yaml

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: olm-operator
  namespace: openshift-operator-lifecycle-manager
  labels:
    app: olm-operator
spec:
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    metricRelabelings:
    - action: drop
      regex: etcd_(debugging|disk|request|server).*
      sourceLabels:
      - __name__
    port: https-metrics
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: olm-operator-metrics.openshift-operator-lifecycle-manager.svc
  jobLabel: component
  namespaceSelector:
    matchNames:
    - openshift-operator-lifecycle-manager
  selector:
    matchLabels:
      app: olm-operator
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: catalog-operator
  namespace: openshift-operator-lifecycle-manager
  labels:
    app: catalog-operator
spec:
  jobLabel: k8s-app
  endpoints:
  - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    interval: 30s
    metricRelabelings:
    - action: drop
      regex: etcd_(debugging|disk|request|server).*
      sourceLabels:
      - __name__
    port: https-metrics
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: catalog-operator-metrics.openshift-operator-lifecycle-manager.svc
  jobLabel: component
  namespaceSelector:
    matchNames:
    - openshift-operator-lifecycle-manager
  selector:
    matchLabels:
      app: catalog-operator
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: operator-lifecycle-manager-metrics
  namespace: openshift-operator-lifecycle-manager
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: operator-lifecycle-manager-metrics
subjects:
- kind: ServiceAccount
  name: prometheus-k8s
  namespace: openshift-monitoring
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: operator-lifecycle-manager-metrics
  namespace: openshift-operator-lifecycle-manager
rules:
- apiGroups:
  - ""
  resources:
  - services
  - endpoints
  - pods
  verbs:
  - get
  - list
  - watch

