From 3b1a3d516838204572adaaec121805438d029844 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 24 Apr 2022 19:32:31 +0200
Subject: [PATCH] feat(matrix): Experiment with database metrics

This patch introduces a postgresql exporter and adds a PodMonitor to
scrape the sources as expected.
---
 apps/base/matrix/database.yaml | 37 ++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/apps/base/matrix/database.yaml b/apps/base/matrix/database.yaml
index d80a855bb..be56c470e 100644
--- a/apps/base/matrix/database.yaml
+++ b/apps/base/matrix/database.yaml
@@ -28,3 +28,40 @@ spec:
     limits:
       cpu: "1"
       memory: 3072Mi
+  sidecars:
+    - name: "exporter"
+      image: "wrouesnel/postgres_exporter"
+      ports:
+        - name: exporter
+          containerPort: 9187
+          protocol: TCP
+      resources:
+        limits:
+          cpu: 500m
+          memory: 256M
+        requests:
+          cpu: 100m
+          memory: 200M
+---
+apiVersion: monitoring.coreos.com/v1
+kind: PodMonitor
+metadata:
+  name: matrix-postgres
+  namespace: matrix
+  labels:
+    app: matrix-postgres
+spec:
+  endpoints:
+    - port: exporter
+      interval: 15s
+      scrapeTimeout: 10s
+  namespaceSelector:
+    matchNames:
+      - matrix
+  selector:
+    matchLabels:
+      cluster-name: matrix-postgres
+  podTargetLabels:
+    - spilo-role
+    - cluster-name
+    - team
-- 
GitLab