Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring: adds podmonitor and prometheusrule for prometheus-operator enabled clusters #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions helm/postgres/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.monitoring }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: postgresql-exporter
spec:
selector:
matchLabels:
postgres-operator.crunchydata.com/crunchy-postgres-exporter: "true"
podMetricsEndpoints:
- port: exporter
relabelings:
- sourceLabels: [__meta_kubernetes_namespace]
action: replace
targetLabel: kubernetes_namespace
- sourceLabels: [__meta_kubernetes_pod_name]
targetLabel: pod
- sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_cluster,__meta_kubernetes_pod_label_pg_cluster]
targetLabel: cluster
separator: ""
replacement: '$1'
- sourceLabels: [__meta_kubernetes_namespace,cluster]
targetLabel: pg_cluster
separator: ":"
replacement: '$1$2'
- sourceLabels: [__meta_kubernetes_pod_ip]
targetLabel: ip
replacement: '$1'
- sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_instance,__meta_kubernetes_pod_label_deployment_name]
targetLabel: deployment
replacement: '$1'
separator: ""
- sourceLabels: [__meta_kubernetes_pod_label_postgres_operator_crunchydata_com_role,__meta_kubernetes_pod_label_role]
targetLabel: role
replacement: '$1'
separator: ""
- sourceLabels: [dbname]
targetLabel: dbname
replacement: '$1'
- sourceLabels: [relname]
targetLabel: relname
replacement: '$1'
- sourceLabels: [schemaname]
targetLabel: schemaname
replacement: '$1'
Comment on lines +37 to +45

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why we need this relabeling?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply copied the complete relabel_config from the original prometheus-config.
https://github.com/dgo19/postgres-operator-examples/blob/main/kustomize/monitoring/prometheus-config.yaml#L65-L73

There are several changes in the last 2 years ;-)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several changes in the last 2 years ;-)

Thanks for mentioning this ;-) I will also have a look directly to these files

{{- end }}
Loading