From a485e241b88e310a48a1c3f335b5b3fd66cdb6de Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Thu, 29 Dec 2022 16:12:15 +0100 Subject: [PATCH] feat: deploy pod monitor to collect metrics --- deploy/caddy/caddy.json | 16 +++++++++++++--- deploy/helm/templates/deployment.yaml | 7 +++++-- deploy/helm/templates/pod_monitor.yaml | 12 ++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 deploy/helm/templates/pod_monitor.yaml diff --git a/deploy/caddy/caddy.json b/deploy/caddy/caddy.json index 5ab2d4c..a0dc24e 100644 --- a/deploy/caddy/caddy.json +++ b/deploy/caddy/caddy.json @@ -14,9 +14,19 @@ "root": "/usr/share/caddy", "index_names": [ "index.html" - ], - "pass_thru": true - }, + ] + } + ] + } + ] + }, + "metrics" : { + "listen": [ + ":9100" + ], + "routes": [ + { + "handle": [ { "handler": "metrics" } diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml index f80cf68..103994f 100644 --- a/deploy/helm/templates/deployment.yaml +++ b/deploy/helm/templates/deployment.yaml @@ -36,14 +36,17 @@ spec: - name: http containerPort: 3000 protocol: TCP + - name: metrics + containerPort: 9100 + protocol: TCP livenessProbe: httpGet: path: /metrics - port: http + port: metrics readinessProbe: httpGet: path: /metrics - port: http + port: metrics resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} diff --git a/deploy/helm/templates/pod_monitor.yaml b/deploy/helm/templates/pod_monitor.yaml new file mode 100644 index 0000000..c421ce2 --- /dev/null +++ b/deploy/helm/templates/pod_monitor.yaml @@ -0,0 +1,12 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "web.fullname" . }} + labels: + {{- include "web.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "web.selectorLabels" . | nindent 6 }} + podMetricsEndpoints: + - port: metrics \ No newline at end of file