diff --git a/infrastructure/charts/node/templates/podmonitor-postgresql.yaml b/infrastructure/charts/node/templates/podmonitor-postgresql.yaml new file mode 100644 index 000000000..91b14f81f --- /dev/null +++ b/infrastructure/charts/node/templates/podmonitor-postgresql.yaml @@ -0,0 +1,14 @@ +{{- if .Values.database.postgres.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: postgres-metrics + namespace: {{ .Release.Namespace }} +spec: + podMetricsEndpoints: + - path: /metrics + port: exporter + selector: + matchLabels: + application: spilo +{{- end }} diff --git a/infrastructure/charts/node/templates/postgresql.yaml b/infrastructure/charts/node/templates/postgresql.yaml index 814e4dc49..5c993b249 100644 --- a/infrastructure/charts/node/templates/postgresql.yaml +++ b/infrastructure/charts/node/templates/postgresql.yaml @@ -19,3 +19,28 @@ spec: prism: prism-admin postgresql: version: "14" +{{- if .Values.database.postgres.metrics.enabled }} + sidecars: + - name: exporter + image: "{{ .Values.database.postgres.metrics.image.repository }}/{{ .Values.database.postgres.metrics.image.tag }}:{{ .Values.database.postgres.metrics.image.version }}" + args: + - --collector.stat_statements + ports: + - name: exporter + containerPort: 9187 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 256M + requests: + cpu: 100m + memory: 256M + env: + - name: DATA_SOURCE_URI + value: "127.0.0.1:5432" + - name: DATA_SOURCE_USER + value: "$(POSTGRES_USER)" + - name: DATA_SOURCE_PASS + value: "$(POSTGRES_PASSWORD)" +{{- end }} diff --git a/infrastructure/charts/node/values.yaml b/infrastructure/charts/node/values.yaml index ec1428a76..f76b14a4f 100644 --- a/infrastructure/charts/node/values.yaml +++ b/infrastructure/charts/node/values.yaml @@ -39,6 +39,12 @@ database: managingTeam: atala databaseSize: 4Gi numberOfInstances: 2 + metrics: + enabled: false + image: + repository: quay.io/prometheuscommunity + tag: postgres-exporter + version: v0.15.0 vdr: externalResources: