|
| 1 | +apiVersion: monitoring.coreos.com/v1 |
| 2 | +kind: PodMonitor |
| 3 | +metadata: |
| 4 | + name: crunchy-otel-collector |
| 5 | +spec: |
| 6 | + selector: |
| 7 | + matchLabels: |
| 8 | + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" |
| 9 | + |
| 10 | + # Uncomment to monitor a single namespace only |
| 11 | + # namespaceSelector: |
| 12 | + # matchNames: |
| 13 | + # - postgres-operator |
| 14 | + |
| 15 | + podMetricsEndpoints: |
| 16 | + - port: otel-metrics |
| 17 | + interval: 15s |
| 18 | + scrapeTimeout: 15s |
| 19 | + relabelings: |
| 20 | + # Keep exporter port and drop all others |
| 21 | + - sourceLabels: [__meta_kubernetes_pod_container_port_number] |
| 22 | + action: keep |
| 23 | + regex: "9187" |
| 24 | + # Set label for namespace |
| 25 | + - sourceLabels: [__meta_kubernetes_namespace] |
| 26 | + targetLabel: kubernetes_namespace |
| 27 | + # Set label for pod name |
| 28 | + - sourceLabels: [__meta_kubernetes_pod_name] |
| 29 | + targetLabel: pod |
| 30 | + # Convert namespace and cluster name to pg_cluster=namespace:cluster |
| 31 | + - sourceLabels: [__meta_kubernetes_namespace,__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_cluster] |
| 32 | + targetLabel: pg_cluster |
| 33 | + separator: ":" |
| 34 | + replacement: '$1$2' |
| 35 | + # Convert kubernetes pod ip to ip |
| 36 | + - sourceLabels: [__meta_kubernetes_pod_ip] |
| 37 | + targetLabel: ip |
| 38 | + # Convert postgres-operator.crunchydata.com/instance to deployment |
| 39 | + - sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_instance] |
| 40 | + targetLabel: deployment |
| 41 | + # Convert postgres-operator.crunchydata.com/role to role |
| 42 | + - sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_role] |
| 43 | + targetLabel: role |
| 44 | + # The following relabels should make it easier to use pgMonitor dashboards. |
| 45 | + # Note: The following was added for the pgBouncer dashboard and what labels it requires. |
| 46 | + # For pgBouncer, `exp_type` should be equal to role. |
| 47 | + - sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_role] |
| 48 | + targetLabel: exp_type |
| 49 | + # `cluster_name` is equivalent to `pg_cluster` |
| 50 | + - sourceLabels: [__meta_kubernetes_namespace,__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_cluster] |
| 51 | + targetLabel: cluster_name |
| 52 | + separator: ":" |
| 53 | + replacement: '$1$2' |
| 54 | +--- |
| 55 | +apiVersion: monitoring.coreos.com/v1 |
| 56 | +kind: PodMonitor |
| 57 | +metadata: |
| 58 | + name: pgo-metrics |
| 59 | +spec: |
| 60 | + selector: |
| 61 | + matchExpressions: |
| 62 | + - key: postgres-operator.crunchydata.com/control-plane |
| 63 | + operator: Exists |
| 64 | + |
| 65 | + # Uncomment to monitor a single namespace only |
| 66 | + # namespaceSelector: |
| 67 | + # matchNames: |
| 68 | + # - postgres-operator |
| 69 | + |
| 70 | + podMetricsEndpoints: |
| 71 | + - port: metrics |
| 72 | + interval: 15s |
| 73 | + scrapeTimeout: 15s |
| 74 | + # If you are running CPK v5.7 or earlier, you will need to change the scheme to 'http' |
| 75 | + # and add a metrics port to the postgres-operator deployment that exposes port 8080. |
| 76 | + scheme: https |
| 77 | + authorization: |
| 78 | + type: Bearer |
| 79 | + credentials: |
| 80 | + name: prometheus-pgo |
| 81 | + key: token |
| 82 | + tlsConfig: |
| 83 | + # By default, the operator's metrics server automatically creates self-signed certs |
| 84 | + # which cannot be verified, so `insecure_skip_verify` is set to `true`. See the |
| 85 | + # documentation for providing your own signed certificates. |
| 86 | + insecureSkipVerify: true |
0 commit comments