diff --git a/internal/otelcollector/config/metric/agent/config.go b/internal/otelcollector/config/metric/agent/config.go index 1195d344e..2a941aab0 100644 --- a/internal/otelcollector/config/metric/agent/config.go +++ b/internal/otelcollector/config/metric/agent/config.go @@ -21,11 +21,25 @@ type Receivers struct { } type KubeletStatsReceiver struct { - CollectionInterval string `yaml:"collection_interval"` - AuthType string `yaml:"auth_type"` - Endpoint string `yaml:"endpoint"` - InsecureSkipVerify bool `yaml:"insecure_skip_verify"` - MetricGroups []MetricGroupType `yaml:"metric_groups"` + CollectionInterval string `yaml:"collection_interval"` + AuthType string `yaml:"auth_type"` + Endpoint string `yaml:"endpoint"` + InsecureSkipVerify bool `yaml:"insecure_skip_verify"` + MetricGroups []MetricGroupType `yaml:"metric_groups"` + Metrics KubeletMetricsConfig `yaml:"metrics"` +} + +type KubeletMetricConfig struct { + Enabled bool `yaml:"enabled"` +} + +type KubeletMetricsConfig struct { + ContainerCPUUsage KubeletMetricConfig `yaml:"container.cpu.usage"` + ContainerCPUUtilization KubeletMetricConfig `yaml:"container.cpu.utilization"` + K8sNodeCPUUsage KubeletMetricConfig `yaml:"k8s.node.cpu.usage"` + K8sNodeCPUUtilization KubeletMetricConfig `yaml:"k8s.node.cpu.utilization"` + K8sPodCPUUsage KubeletMetricConfig `yaml:"k8s.pod.cpu.usage"` + K8sPodCPUUtilization KubeletMetricConfig `yaml:"k8s.pod.cpu.utilization"` } type MetricGroupType string diff --git a/internal/otelcollector/config/metric/agent/receivers.go b/internal/otelcollector/config/metric/agent/receivers.go index 9cdee93f2..73715d6b8 100644 --- a/internal/otelcollector/config/metric/agent/receivers.go +++ b/internal/otelcollector/config/metric/agent/receivers.go @@ -47,6 +47,14 @@ func makeKubeletStatsConfig() *KubeletStatsReceiver { InsecureSkipVerify: true, Endpoint: fmt.Sprintf("https://${env:%s}:%d", config.EnvVarCurrentNodeName, portKubelet), MetricGroups: []MetricGroupType{MetricGroupTypeContainer, MetricGroupTypePod}, + Metrics: KubeletMetricsConfig{ + ContainerCPUUsage: KubeletMetricConfig{Enabled: true}, + ContainerCPUUtilization: KubeletMetricConfig{Enabled: false}, + K8sNodeCPUUsage: KubeletMetricConfig{Enabled: true}, + K8sNodeCPUUtilization: KubeletMetricConfig{Enabled: false}, + K8sPodCPUUsage: KubeletMetricConfig{Enabled: true}, + K8sPodCPUUtilization: KubeletMetricConfig{Enabled: false}, + }, } } diff --git a/internal/otelcollector/config/metric/agent/testdata/config_istio_active.yaml b/internal/otelcollector/config/metric/agent/testdata/config_istio_active.yaml index cc54ac984..7b43f742c 100644 --- a/internal/otelcollector/config/metric/agent/testdata/config_istio_active.yaml +++ b/internal/otelcollector/config/metric/agent/testdata/config_istio_active.yaml @@ -52,6 +52,19 @@ receivers: metric_groups: - container - pod + metrics: + container.cpu.usage: + enabled: true + container.cpu.utilization: + enabled: false + k8s.node.cpu.usage: + enabled: true + k8s.node.cpu.utilization: + enabled: false + k8s.pod.cpu.usage: + enabled: true + k8s.pod.cpu.utilization: + enabled: false prometheus/app-pods: config: scrape_configs: diff --git a/internal/otelcollector/config/metric/agent/testdata/config_istio_not_active.yaml b/internal/otelcollector/config/metric/agent/testdata/config_istio_not_active.yaml index 4d455a699..02ab95e3c 100644 --- a/internal/otelcollector/config/metric/agent/testdata/config_istio_not_active.yaml +++ b/internal/otelcollector/config/metric/agent/testdata/config_istio_not_active.yaml @@ -52,6 +52,19 @@ receivers: metric_groups: - container - pod + metrics: + container.cpu.usage: + enabled: true + container.cpu.utilization: + enabled: false + k8s.node.cpu.usage: + enabled: true + k8s.node.cpu.utilization: + enabled: false + k8s.pod.cpu.usage: + enabled: true + k8s.pod.cpu.utilization: + enabled: false prometheus/app-pods: config: scrape_configs: diff --git a/test/testkit/otel/kubeletstats/metrics.go b/test/testkit/otel/kubeletstats/metrics.go index 703ac146d..f8ff461d9 100644 --- a/test/testkit/otel/kubeletstats/metrics.go +++ b/test/testkit/otel/kubeletstats/metrics.go @@ -3,7 +3,7 @@ package kubeletstats var ( MetricNames = []string{ "container.cpu.time", - "container.cpu.utilization", + "container.cpu.usage", "container.filesystem.available", "container.filesystem.capacity", "container.filesystem.usage", @@ -14,7 +14,7 @@ var ( "container.memory.usage", "container.memory.working_set", "k8s.pod.cpu.time", - "k8s.pod.cpu.utilization", + "k8s.pod.cpu.usage", "k8s.pod.filesystem.available", "k8s.pod.filesystem.capacity", "k8s.pod.filesystem.usage",