Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add cpu.usage metrics and disable cpu.utilization metrics #855

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions internal/otelcollector/config/metric/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions internal/otelcollector/config/metric/agent/receivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/testkit/otel/kubeletstats/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Loading