From fbe07176ee4e0ca2ed514153a0dae02ba0fdf56e Mon Sep 17 00:00:00 2001 From: Alex Lew Date: Wed, 19 Mar 2025 11:24:11 -0700 Subject: [PATCH] feat: remove some resource labels from prometheus metrics --- charts/agent/Chart.yaml | 2 +- charts/agent/README.md | 2 +- .../templates/_cluster-metrics-config.tpl | 38 +++++++++++-------- charts/agent/templates/_config-processors.tpl | 23 +++++++++-- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/charts/agent/Chart.yaml b/charts/agent/Chart.yaml index a397d6c9..4488febd 100644 --- a/charts/agent/Chart.yaml +++ b/charts/agent/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: agent description: Chart to install K8s collection stack based on Observe Agent type: application -version: 0.46.1 +version: 0.47.0 appVersion: "1.1.0" dependencies: - name: opentelemetry-collector diff --git a/charts/agent/README.md b/charts/agent/README.md index 100414a3..395aca61 100644 --- a/charts/agent/README.md +++ b/charts/agent/README.md @@ -1,6 +1,6 @@ # agent -![Version: 0.46.1](https://img.shields.io/badge/Version-0.46.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) +![Version: 0.47.0](https://img.shields.io/badge/Version-0.47.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) Chart to install K8s collection stack based on Observe Agent diff --git a/charts/agent/templates/_cluster-metrics-config.tpl b/charts/agent/templates/_cluster-metrics-config.tpl index feb3fd6a..4731ac90 100644 --- a/charts/agent/templates/_cluster-metrics-config.tpl +++ b/charts/agent/templates/_cluster-metrics-config.tpl @@ -117,20 +117,6 @@ receivers: target_label: __address__ ################################################################ - # Maps all Kubernetes pod labels to Prometheus labels with the prefix removed (e.g., __meta_kubernetes_pod_label_app becomes app). - - action: labelmap - regex: __meta_kubernetes_pod_label_(.+) - - # adds new label - - source_labels: [__meta_kubernetes_namespace] - action: replace - target_label: kubernetes_namespace - - # adds new label - - source_labels: [__meta_kubernetes_pod_name] - action: replace - target_label: kubernetes_pod_name - metric_relabel_configs: - action: drop regex: {{.Values.application.prometheusScrape.metricDropRegex}} @@ -150,6 +136,28 @@ processors: {{- include "config.processors.attributes.k8sattributes" . | nindent 2 }} {{- include "config.processors.resource.observe_common" . | nindent 2 }} + resource/drop_additional_pod_metrics_labels: + attributes: + - key: http.scheme + action: delete + - key: net.host.name + action: delete + - key: net.host.port + action: delete + - key: server.address + action: delete + - key: server.port + action: delete + - key: service.instance.id + action: delete + - key: url.scheme + action: delete + - key: instance + action: delete + - key: k8s.pod.uid + action: delete + - key: job + action: delete # attributes to append to objects attributes/debug_source_cluster_metrics: @@ -181,7 +189,7 @@ service: {{- if .Values.application.prometheusScrape.enabled }} metrics/pod_metrics: receivers: [prometheus/pod_metrics] - processors: [memory_limiter, k8sattributes, batch, resource/observe_common, attributes/debug_source_pod_metrics] + processors: [memory_limiter, k8sattributes, resource/drop_additional_pod_metrics_labels, batch, resource/observe_common, attributes/debug_source_pod_metrics] exporters: [{{ join ", " $podMetricsExporters }}] {{ end -}} {{- include "config.service.telemetry" . | nindent 2 }} diff --git a/charts/agent/templates/_config-processors.tpl b/charts/agent/templates/_config-processors.tpl index c4738000..9197f08a 100644 --- a/charts/agent/templates/_config-processors.tpl +++ b/charts/agent/templates/_config-processors.tpl @@ -32,17 +32,32 @@ k8sattributes: - k8s.pod.uid - k8s.cluster.uid - k8s.node.name - - k8s.node.uid - k8s.container.name - container.id + labels: + - tag_name: app.kubernetes.io/name + key: app.kubernetes.io/name + from: pod + - tag_name: app.kubernetes.io/instance + key: app.kubernetes.io/instance + from: pod + - tag_name: app.kubernetes.io/version + key: app.kubernetes.io/version + from: pod + - tag_name: app.kubernetes.io/component + key: app.kubernetes.io/component + from: pod + - tag_name: app.kubernetes.io/part-of + key: app.kubernetes.io/part-of + from: pod + - tag_name: app.kubernetes.io/managed-by + key: app.kubernetes.io/managed-by + from: pod passthrough: false pod_association: - sources: - from: resource_attribute name: k8s.pod.ip - # - sources: - # - from: resource_attribute - # name: k8s.container.restart_count - sources: - from: resource_attribute name: k8s.pod.uid