---
# yaml-language-server: $schema=https://ks.hsn.dev/monitoring.coreos.com/podmonitor_v1.json
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: cpgo-postgres
spec:
  jobLabel: cpgo-postgres
  namespaceSelector:
    matchNames:
      - database
  podMetricsEndpoints:
    - honorLabels: true
      path: /metrics
      port: exporter
      relabelings:
        - sourceLabels:
            [
              "__meta_kubernetes_namespace",
              "__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_cluster",
            ]
          targetLabel: pg_cluster
          separator: "/"
          replacement: "$1$2"
        - sourceLabels:
            [
              __meta_kubernetes_pod_label_postgres_operator_crunchydata_com_instance,
            ]
          targetLabel: deployment
        - sourceLabels:
            [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_role]
          targetLabel: role
        - sourceLabels: [__meta_kubernetes_pod_name]
          targetLabel: instance
  selector:
    matchLabels:
      postgres-operator.crunchydata.com/cluster: postgres
      postgres-operator.crunchydata.com/crunchy-postgres-exporter: "true"