From 2ec8fb390f07b22a256a9c72de3c0b0aace718a0 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 5 Dec 2024 22:26:53 +0100 Subject: [PATCH] feat(metrics): Add node and kube metrics --- manifests/kube-state-metrics/kustomization.yaml | 7 +++++++ manifests/kube-state-metrics/servicemonitor.yaml | 13 +++++++++++++ manifests/kustomization.yaml | 1 + manifests/node-exporter/daemonset.yaml | 3 +-- manifests/node-exporter/servicemonitor.yaml | 3 +++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 manifests/kube-state-metrics/kustomization.yaml create mode 100644 manifests/kube-state-metrics/servicemonitor.yaml diff --git a/manifests/kube-state-metrics/kustomization.yaml b/manifests/kube-state-metrics/kustomization.yaml new file mode 100644 index 0000000..b30f242 --- /dev/null +++ b/manifests/kube-state-metrics/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: monitoring + +resources: + - git@github.com:kubernetes/kube-state-metrics/examples/standard?ref=v2.14.0 + - servicemonitor.yaml diff --git a/manifests/kube-state-metrics/servicemonitor.yaml b/manifests/kube-state-metrics/servicemonitor.yaml new file mode 100644 index 0000000..1fb7400 --- /dev/null +++ b/manifests/kube-state-metrics/servicemonitor.yaml @@ -0,0 +1,13 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: kube-state-metrics + namespace: monitoring +spec: + selector: + matchLabels: + app.kubernetes.io/component: exporter + app.kubernetes.io/name: kube-state-metrics + endpoints: + - port: http-metrics + path: /metrics diff --git a/manifests/kustomization.yaml b/manifests/kustomization.yaml index 8afc7ec..688c2c3 100644 --- a/manifests/kustomization.yaml +++ b/manifests/kustomization.yaml @@ -10,3 +10,4 @@ resources: - prometheus - grafana - node-exporter + - kube-state-metrics diff --git a/manifests/node-exporter/daemonset.yaml b/manifests/node-exporter/daemonset.yaml index 14c1d0c..6e1e2a7 100644 --- a/manifests/node-exporter/daemonset.yaml +++ b/manifests/node-exporter/daemonset.yaml @@ -22,8 +22,7 @@ spec: - --path.sysfs=/host/sys - --path.rootfs=/host/root - --no-collector.wifi - - --no-collector.hwmon - - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/) + - --collector.filesystem.ignored-mount-points=^/(dev|proc|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/) - --collector.netclass.ignored-devices=^(veth.*)$ name: node-exporter image: prom/node-exporter diff --git a/manifests/node-exporter/servicemonitor.yaml b/manifests/node-exporter/servicemonitor.yaml index 4818379..7957945 100644 --- a/manifests/node-exporter/servicemonitor.yaml +++ b/manifests/node-exporter/servicemonitor.yaml @@ -11,3 +11,6 @@ spec: endpoints: - port: node-exporter path: /metrics + relabelings: + - sourceLabels: [__meta_kubernetes_pod_node_name] + targetLabel: instance