From d7e14f9b35e64ed3106db76c67dce8d5edff9de3 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Sat, 29 Jul 2023 09:44:09 +0200 Subject: [PATCH] feat(prometheus): Add self scraping --- manifests/prometheus/kustomization.yaml | 2 ++ manifests/prometheus/prometheus.yaml | 3 +++ manifests/prometheus/service.yaml | 16 ++++++++++++++++ manifests/prometheus/servicemonitor.yaml | 14 ++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 manifests/prometheus/service.yaml create mode 100644 manifests/prometheus/servicemonitor.yaml diff --git a/manifests/prometheus/kustomization.yaml b/manifests/prometheus/kustomization.yaml index 723baa6..5dc83e0 100644 --- a/manifests/prometheus/kustomization.yaml +++ b/manifests/prometheus/kustomization.yaml @@ -2,4 +2,6 @@ resources: - serviceaccount.yaml - clusterrole.yaml - clusterrolebinding.yaml + - service.yaml + - servicemonitor.yaml - prometheus.yaml diff --git a/manifests/prometheus/prometheus.yaml b/manifests/prometheus/prometheus.yaml index f9f79f0..8496f03 100644 --- a/manifests/prometheus/prometheus.yaml +++ b/manifests/prometheus/prometheus.yaml @@ -7,6 +7,9 @@ spec: serviceAccountName: prometheus serviceMonitorNamespaceSelector: {} serviceMonitorSelector: {} + podMonitorSelector: + matchLabels: + team: core resources: requests: memory: 300Mi diff --git a/manifests/prometheus/service.yaml b/manifests/prometheus/service.yaml new file mode 100644 index 0000000..7ccddcd --- /dev/null +++ b/manifests/prometheus/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: prometheus-svc + namespace: monitoring + labels: + app.kubernetes.io/name: prometheus +spec: + ports: + - name: web + port: 9090 + protocol: TCP + targetPort: web + selector: + app.kubernetes.io/name: prometheus + diff --git a/manifests/prometheus/servicemonitor.yaml b/manifests/prometheus/servicemonitor.yaml new file mode 100644 index 0000000..ceb46bc --- /dev/null +++ b/manifests/prometheus/servicemonitor.yaml @@ -0,0 +1,14 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: prometheus + namespace: monitoring + labels: + team: core +spec: + selector: + matchLabels: + app.kubernetes.io/name: prometheus + endpoints: + - port: web + path: /metrics