From 8da4754568fa6eb25fc47b00411106b1738d7318 Mon Sep 17 00:00:00 2001 From: Enrico Giorio Date: Wed, 27 Nov 2024 15:14:21 +0000 Subject: [PATCH] feat: Populate metric unit of cpu metrics Set the unit to "CPU" when the metric name contains *cpu* and the unit is not already set. --- charts/agent/Chart.yaml | 2 +- charts/agent/README.md | 2 +- charts/agent/templates/_cluster-metrics-config.tpl | 9 ++++++--- charts/agent/templates/_config-processors.tpl | 10 ++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/charts/agent/Chart.yaml b/charts/agent/Chart.yaml index 5c6b18d4..0dfe0237 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.30.6 +version: 0.31.0 appVersion: "1.1.0" dependencies: - name: opentelemetry-collector diff --git a/charts/agent/README.md b/charts/agent/README.md index 5dddd860..7f07d2b5 100644 --- a/charts/agent/README.md +++ b/charts/agent/README.md @@ -1,6 +1,6 @@ # agent -![Version: 0.30.6](https://img.shields.io/badge/Version-0.30.6-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.31.0](https://img.shields.io/badge/Version-0.31.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) > [!CAUTION] > This chart is under active development and is not meant to be installed yet. diff --git a/charts/agent/templates/_cluster-metrics-config.tpl b/charts/agent/templates/_cluster-metrics-config.tpl index d5a619bb..0ed354cb 100644 --- a/charts/agent/templates/_cluster-metrics-config.tpl +++ b/charts/agent/templates/_cluster-metrics-config.tpl @@ -151,6 +151,8 @@ processors: {{- include "config.processors.resource.observe_common" . | nindent 2 }} +{{- include "config.processors.transform.metrics" . | nindent 2 }} + # attributes to append to objects attributes/debug_source_cluster_metrics: actions: @@ -163,19 +165,20 @@ processors: action: insert value: pod_metrics + service: extensions: [health_check] pipelines: metrics: receivers: [k8s_cluster] - processors: [memory_limiter, k8sattributes, batch, resource/observe_common, attributes/debug_source_cluster_metrics] + processors: [memory_limiter, k8sattributes, batch, resource/observe_common, attributes/debug_source_cluster_metrics, transform/metrics] exporters: [prometheusremotewrite, debug/override] {{- 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, batch, resource/observe_common, attributes/debug_source_pod_metrics, transform/metrics] exporters: [prometheusremotewrite, debug/override] {{ end -}} {{- include "config.service.telemetry" . | nindent 2 }} - {{- end }} +{{- end }} diff --git a/charts/agent/templates/_config-processors.tpl b/charts/agent/templates/_config-processors.tpl index 4962a652..4cac1fce 100644 --- a/charts/agent/templates/_config-processors.tpl +++ b/charts/agent/templates/_config-processors.tpl @@ -87,3 +87,13 @@ memory_limiter: {{- define "config.processors.attributes.observek8sattributes" -}} observek8sattributes: {{- end -}} + +{{- define "config.processors.transform.metrics" -}} +transform/metrics: + metric_statements: + - context: metric + statements: + - set(unit, "test") + # - set(unit, "cores") where unit == "" + # - set(unit, "cores") where IsMatch(name, ".*cpu.*") +{{- end -}}