diff --git a/.chloggen/kubeletstatsreceiver-struct-changes.yaml b/.chloggen/kubeletstatsreceiver-struct-changes.yaml new file mode 100644 index 000000000000..deb211d517a6 --- /dev/null +++ b/.chloggen/kubeletstatsreceiver-struct-changes.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. +# If your change doesn't affect end users, such as a test fix or a tooling change, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: kubeletstatsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change the type from RecordDoubleDataPointFunc to []RecordDoubleDataPointFunc for CPUMetrics.{Time,Utilization}, and from RecordIntDataPointFunc to []RecordIntDataPointFunc for MemoryMetrics.{Available,Usage,Rss,WorkingSet,PageFaults,MajorPageFaults} and FilesystemMetrics.{Available,Capacity,Usage}. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [24238] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/.chloggen/prepend-container-metrics-k8s.yaml b/.chloggen/prepend-container-metrics-k8s.yaml new file mode 100755 index 000000000000..fc75842e5720 --- /dev/null +++ b/.chloggen/prepend-container-metrics-k8s.yaml @@ -0,0 +1,46 @@ +# Use this changelog template to create an entry for release notes. +# If your change doesn't affect end users, such as a test fix or a tooling change, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: kubestatsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: container.* metrics will be deprecated in v0.82.0 in favor of their k8s.container.* counterparts + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [24238] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: | + This starts the process of phasing out container.* metrics: + - `container.cpu.utilization` + - `container.cpu.time` + - `container.memory.available` + - `container.memory.usage` + - `container.memory.rss` + - `container.memory.working_set` + - `container.memory.page_faults` + - `container.memory.major_page_faults` + - `container.filesystem.available` + - `container.filesystem.capacity` + - `container.filesystem.usage` + and replacing it with their k8s.container* counterparts: + - `k8s.container.cpu.utilization` + - `k8s.container.cpu.time` + - `k8s.container.memory.available` + - `k8s.container.memory.usage` + - `k8s.container.memory.rss` + - `k8s.container.memory.working_set` + - `k8s.container.memory.page_faults` + - `k8s.container.memory.major_page_faults` + - `k8s.container.filesystem.available` + - `k8s.container.filesystem.capacity` + - `k8s.container.filesystem.usage` + At this stage, the new metric is added, but is disabled by default. + See the "Deprecations" section of the Kubelet Stats receiver's README for details. diff --git a/receiver/kubeletstatsreceiver/README.md b/receiver/kubeletstatsreceiver/README.md index a1a6454aaf32..bb527adda36e 100644 --- a/receiver/kubeletstatsreceiver/README.md +++ b/receiver/kubeletstatsreceiver/README.md @@ -225,3 +225,70 @@ with detailed sample configurations [here](./testdata/config.yaml). ## Metrics Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml) with further documentation in [documentation.md](./documentation.md) + +## Deprecations + +### container.* metrics deprecated in favor of k8s.container.* metrics + +All `container.*` metrics have been deprecated in favor of their `k8s.container.*` counterparts + +The following process will be followed to phase out the old metrics: + +- In `v0.82.0`, the new metric is introduced and the old metric is marked as deprecated. + Only the old metric are emitted by default. +- In `v0.84.0`, the old metric is disabled and the new one enabled by default. +- In `v0.86.0` and up, the old metric is removed. + +To change the enabled state for the specific metrics, use the standard configuration options that are available for all metrics. + +Here's an example configuration to disable the old metrics and enable the new metrics: + +```yaml +receivers: + kubeletstats: + metrics: + container.cpu.utilization: + enabled: false + k8s.container.cpu.utilization: + enabled: true + container.cpu.time: + enabled: false + k8s.container.cpu.time: + enabled: true + container.memory.available: + enabled: false + k8s.container.memory.available: + enabled: true + container.memory.usage: + enabled: false + k8s.container.memory.usage: + enabled: true + container.memory.rss: + enabled: false + k8s.container.memory.rss: + enabled: true + container.memory.working_set: + enabled: false + k8s.container.memory.working_set: + enabled: true + container.memory.page_faults: + enabled: false + k8s.container.memory.page_faults: + enabled: true + container.memory.major_page_faults: + enabled: false + k8s.container.memory.major_page_faults: + enabled: true + container.filesystem.available: + enabled: false + k8s.container.filesystem.available: + enabled: true + container.filesystem.capacity: + enabled: false + k8s.container.filesystem.capacity: + enabled: true + container.filesystem.usage: + enabled: false + k8s.container.filesystem.usage: + enabled: true +``` diff --git a/receiver/kubeletstatsreceiver/documentation.md b/receiver/kubeletstatsreceiver/documentation.md index ce731241a56b..26d0626ce9d3 100644 --- a/receiver/kubeletstatsreceiver/documentation.md +++ b/receiver/kubeletstatsreceiver/documentation.md @@ -14,7 +14,7 @@ metrics: ### container.cpu.time -Container CPU time +Deprecated: use `k8s.container.cpu.time` metric instead. Container CPU time | Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ---- | ----------- | ---------- | ----------------------- | --------- | @@ -22,7 +22,7 @@ Container CPU time ### container.cpu.utilization -Container CPU utilization +Deprecated: use `k8s.container.cpu.utilization` metric instead. Container CPU utilization | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -30,7 +30,7 @@ Container CPU utilization ### container.filesystem.available -Container filesystem available +Deprecated: use `k8s.container.filesystem.available` metric instead. Container filesystem available | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -38,7 +38,7 @@ Container filesystem available ### container.filesystem.capacity -Container filesystem capacity +Deprecated: use `k8s.container.filesystem.capacity` metric instead. Container filesystem capacity | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -46,7 +46,7 @@ Container filesystem capacity ### container.filesystem.usage -Container filesystem usage +Deprecated: use `k8s.container.filesystem.usage` metric instead. Container filesystem usage | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -54,7 +54,7 @@ Container filesystem usage ### container.memory.available -Container memory available +Deprecated: use `k8s.container.memory.available` metric instead. Container memory available | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -62,7 +62,7 @@ Container memory available ### container.memory.major_page_faults -Container memory major_page_faults +Deprecated: use `container.memory.major_page_faults` metric instead. Container memory major_page_faults | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -70,7 +70,7 @@ Container memory major_page_faults ### container.memory.page_faults -Container memory page_faults +Deprecated: use `k8s.container.memory.page_faults` metric instead. Container memory page_faults | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -78,7 +78,7 @@ Container memory page_faults ### container.memory.rss -Container memory rss +Deprecated: use `k8s.container.memory.rss` metric instead. Container memory rss | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -86,7 +86,7 @@ Container memory rss ### container.memory.usage -Container memory usage +Deprecated: use `k8s.container.memory.usage` metric instead. Container memory usage | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -94,7 +94,7 @@ Container memory usage ### container.memory.working_set -Container memory working_set +Deprecated: use `k8s.container.memory.working_set` metric instead. Container memory working_set | Unit | Metric Type | Value Type | | ---- | ----------- | ---------- | @@ -376,6 +376,104 @@ The inodes used by the filesystem. This may not equal inodes - free because file | ---- | ----------- | ---------- | | 1 | Gauge | Int | +## Optional Metrics + +The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration: + +```yaml +metrics: + : + enabled: true +``` + +### k8s.container.cpu.time + +Container CPU time + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| s | Sum | Double | Cumulative | true | + +### k8s.container.cpu.utilization + +Container CPU utilization + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| 1 | Gauge | Double | + +### k8s.container.filesystem.available + +Container filesystem available + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.filesystem.capacity + +Container filesystem capacity + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.filesystem.usage + +Container filesystem usage + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.memory.available + +Container memory available + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.memory.major_page_faults + +Container memory major_page_faults + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| 1 | Gauge | Int | + +### k8s.container.memory.page_faults + +Container memory page_faults + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| 1 | Gauge | Int | + +### k8s.container.memory.rss + +Container memory rss + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.memory.usage + +Container memory usage + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + +### k8s.container.memory.working_set + +Container memory working_set + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| By | Gauge | Int | + ## Resource Attributes | Name | Description | Values | Enabled | diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/cpu.go b/receiver/kubeletstatsreceiver/internal/kubelet/cpu.go index ad5d617efa21..e06a438eb21e 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/cpu.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/cpu.go @@ -14,8 +14,12 @@ func addCPUMetrics(mb *metadata.MetricsBuilder, cpuMetrics metadata.CPUMetrics, if s == nil { return } - addCPUUsageMetric(mb, cpuMetrics.Utilization, s, currentTime) - addCPUTimeMetric(mb, cpuMetrics.Time, s, currentTime) + for _, recordDataPoint := range cpuMetrics.Utilization { + addCPUUsageMetric(mb, recordDataPoint, s, currentTime) + } + for _, recordDataPoint := range cpuMetrics.Time { + addCPUTimeMetric(mb, recordDataPoint, s, currentTime) + } } func addCPUUsageMetric(mb *metadata.MetricsBuilder, recordDataPoint metadata.RecordDoubleDataPointFunc, s *stats.CPUStats, currentTime pcommon.Timestamp) { diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/fs.go b/receiver/kubeletstatsreceiver/internal/kubelet/fs.go index 2c2ae1f843d5..9172d4b41455 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/fs.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/fs.go @@ -14,8 +14,13 @@ func addFilesystemMetrics(mb *metadata.MetricsBuilder, filesystemMetrics metadat if s == nil { return } - - recordIntDataPoint(mb, filesystemMetrics.Available, s.AvailableBytes, currentTime) - recordIntDataPoint(mb, filesystemMetrics.Capacity, s.CapacityBytes, currentTime) - recordIntDataPoint(mb, filesystemMetrics.Usage, s.UsedBytes, currentTime) + for _, recordDataPoint := range filesystemMetrics.Available { + recordIntDataPoint(mb, recordDataPoint, s.AvailableBytes, currentTime) + } + for _, recordDataPoint := range filesystemMetrics.Capacity { + recordIntDataPoint(mb, recordDataPoint, s.CapacityBytes, currentTime) + } + for _, recordDataPoint := range filesystemMetrics.Usage { + recordIntDataPoint(mb, recordDataPoint, s.UsedBytes, currentTime) + } } diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/mem.go b/receiver/kubeletstatsreceiver/internal/kubelet/mem.go index 977f21b8bb8f..41d37fe4a5c7 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/mem.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/mem.go @@ -14,11 +14,22 @@ func addMemoryMetrics(mb *metadata.MetricsBuilder, memoryMetrics metadata.Memory if s == nil { return } - - recordIntDataPoint(mb, memoryMetrics.Available, s.AvailableBytes, currentTime) - recordIntDataPoint(mb, memoryMetrics.Usage, s.UsageBytes, currentTime) - recordIntDataPoint(mb, memoryMetrics.Rss, s.RSSBytes, currentTime) - recordIntDataPoint(mb, memoryMetrics.WorkingSet, s.WorkingSetBytes, currentTime) - recordIntDataPoint(mb, memoryMetrics.PageFaults, s.PageFaults, currentTime) - recordIntDataPoint(mb, memoryMetrics.MajorPageFaults, s.MajorPageFaults, currentTime) + for _, recordDataPoint := range memoryMetrics.Available { + recordIntDataPoint(mb, recordDataPoint, s.AvailableBytes, currentTime) + } + for _, recordDataPoint := range memoryMetrics.Usage { + recordIntDataPoint(mb, recordDataPoint, s.UsageBytes, currentTime) + } + for _, recordDataPoint := range memoryMetrics.Rss { + recordIntDataPoint(mb, recordDataPoint, s.RSSBytes, currentTime) + } + for _, recordDataPoint := range memoryMetrics.WorkingSet { + recordIntDataPoint(mb, recordDataPoint, s.WorkingSetBytes, currentTime) + } + for _, recordDataPoint := range memoryMetrics.PageFaults { + recordIntDataPoint(mb, recordDataPoint, s.PageFaults, currentTime) + } + for _, recordDataPoint := range memoryMetrics.MajorPageFaults { + recordIntDataPoint(mb, recordDataPoint, s.MajorPageFaults, currentTime) + } } diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go index d6cf6f86d3c9..30a14e4e95b7 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go @@ -25,48 +25,59 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { // MetricsConfig provides config for kubeletstats metrics. type MetricsConfig struct { - ContainerCPUTime MetricConfig `mapstructure:"container.cpu.time"` - ContainerCPUUtilization MetricConfig `mapstructure:"container.cpu.utilization"` - ContainerFilesystemAvailable MetricConfig `mapstructure:"container.filesystem.available"` - ContainerFilesystemCapacity MetricConfig `mapstructure:"container.filesystem.capacity"` - ContainerFilesystemUsage MetricConfig `mapstructure:"container.filesystem.usage"` - ContainerMemoryAvailable MetricConfig `mapstructure:"container.memory.available"` - ContainerMemoryMajorPageFaults MetricConfig `mapstructure:"container.memory.major_page_faults"` - ContainerMemoryPageFaults MetricConfig `mapstructure:"container.memory.page_faults"` - ContainerMemoryRss MetricConfig `mapstructure:"container.memory.rss"` - ContainerMemoryUsage MetricConfig `mapstructure:"container.memory.usage"` - ContainerMemoryWorkingSet MetricConfig `mapstructure:"container.memory.working_set"` - K8sNodeCPUTime MetricConfig `mapstructure:"k8s.node.cpu.time"` - K8sNodeCPUUtilization MetricConfig `mapstructure:"k8s.node.cpu.utilization"` - K8sNodeFilesystemAvailable MetricConfig `mapstructure:"k8s.node.filesystem.available"` - K8sNodeFilesystemCapacity MetricConfig `mapstructure:"k8s.node.filesystem.capacity"` - K8sNodeFilesystemUsage MetricConfig `mapstructure:"k8s.node.filesystem.usage"` - K8sNodeMemoryAvailable MetricConfig `mapstructure:"k8s.node.memory.available"` - K8sNodeMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.node.memory.major_page_faults"` - K8sNodeMemoryPageFaults MetricConfig `mapstructure:"k8s.node.memory.page_faults"` - K8sNodeMemoryRss MetricConfig `mapstructure:"k8s.node.memory.rss"` - K8sNodeMemoryUsage MetricConfig `mapstructure:"k8s.node.memory.usage"` - K8sNodeMemoryWorkingSet MetricConfig `mapstructure:"k8s.node.memory.working_set"` - K8sNodeNetworkErrors MetricConfig `mapstructure:"k8s.node.network.errors"` - K8sNodeNetworkIo MetricConfig `mapstructure:"k8s.node.network.io"` - K8sPodCPUTime MetricConfig `mapstructure:"k8s.pod.cpu.time"` - K8sPodCPUUtilization MetricConfig `mapstructure:"k8s.pod.cpu.utilization"` - K8sPodFilesystemAvailable MetricConfig `mapstructure:"k8s.pod.filesystem.available"` - K8sPodFilesystemCapacity MetricConfig `mapstructure:"k8s.pod.filesystem.capacity"` - K8sPodFilesystemUsage MetricConfig `mapstructure:"k8s.pod.filesystem.usage"` - K8sPodMemoryAvailable MetricConfig `mapstructure:"k8s.pod.memory.available"` - K8sPodMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.pod.memory.major_page_faults"` - K8sPodMemoryPageFaults MetricConfig `mapstructure:"k8s.pod.memory.page_faults"` - K8sPodMemoryRss MetricConfig `mapstructure:"k8s.pod.memory.rss"` - K8sPodMemoryUsage MetricConfig `mapstructure:"k8s.pod.memory.usage"` - K8sPodMemoryWorkingSet MetricConfig `mapstructure:"k8s.pod.memory.working_set"` - K8sPodNetworkErrors MetricConfig `mapstructure:"k8s.pod.network.errors"` - K8sPodNetworkIo MetricConfig `mapstructure:"k8s.pod.network.io"` - K8sVolumeAvailable MetricConfig `mapstructure:"k8s.volume.available"` - K8sVolumeCapacity MetricConfig `mapstructure:"k8s.volume.capacity"` - K8sVolumeInodes MetricConfig `mapstructure:"k8s.volume.inodes"` - K8sVolumeInodesFree MetricConfig `mapstructure:"k8s.volume.inodes.free"` - K8sVolumeInodesUsed MetricConfig `mapstructure:"k8s.volume.inodes.used"` + ContainerCPUTime MetricConfig `mapstructure:"container.cpu.time"` + ContainerCPUUtilization MetricConfig `mapstructure:"container.cpu.utilization"` + ContainerFilesystemAvailable MetricConfig `mapstructure:"container.filesystem.available"` + ContainerFilesystemCapacity MetricConfig `mapstructure:"container.filesystem.capacity"` + ContainerFilesystemUsage MetricConfig `mapstructure:"container.filesystem.usage"` + ContainerMemoryAvailable MetricConfig `mapstructure:"container.memory.available"` + ContainerMemoryMajorPageFaults MetricConfig `mapstructure:"container.memory.major_page_faults"` + ContainerMemoryPageFaults MetricConfig `mapstructure:"container.memory.page_faults"` + ContainerMemoryRss MetricConfig `mapstructure:"container.memory.rss"` + ContainerMemoryUsage MetricConfig `mapstructure:"container.memory.usage"` + ContainerMemoryWorkingSet MetricConfig `mapstructure:"container.memory.working_set"` + K8sContainerCPUTime MetricConfig `mapstructure:"k8s.container.cpu.time"` + K8sContainerCPUUtilization MetricConfig `mapstructure:"k8s.container.cpu.utilization"` + K8sContainerFilesystemAvailable MetricConfig `mapstructure:"k8s.container.filesystem.available"` + K8sContainerFilesystemCapacity MetricConfig `mapstructure:"k8s.container.filesystem.capacity"` + K8sContainerFilesystemUsage MetricConfig `mapstructure:"k8s.container.filesystem.usage"` + K8sContainerMemoryAvailable MetricConfig `mapstructure:"k8s.container.memory.available"` + K8sContainerMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.container.memory.major_page_faults"` + K8sContainerMemoryPageFaults MetricConfig `mapstructure:"k8s.container.memory.page_faults"` + K8sContainerMemoryRss MetricConfig `mapstructure:"k8s.container.memory.rss"` + K8sContainerMemoryUsage MetricConfig `mapstructure:"k8s.container.memory.usage"` + K8sContainerMemoryWorkingSet MetricConfig `mapstructure:"k8s.container.memory.working_set"` + K8sNodeCPUTime MetricConfig `mapstructure:"k8s.node.cpu.time"` + K8sNodeCPUUtilization MetricConfig `mapstructure:"k8s.node.cpu.utilization"` + K8sNodeFilesystemAvailable MetricConfig `mapstructure:"k8s.node.filesystem.available"` + K8sNodeFilesystemCapacity MetricConfig `mapstructure:"k8s.node.filesystem.capacity"` + K8sNodeFilesystemUsage MetricConfig `mapstructure:"k8s.node.filesystem.usage"` + K8sNodeMemoryAvailable MetricConfig `mapstructure:"k8s.node.memory.available"` + K8sNodeMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.node.memory.major_page_faults"` + K8sNodeMemoryPageFaults MetricConfig `mapstructure:"k8s.node.memory.page_faults"` + K8sNodeMemoryRss MetricConfig `mapstructure:"k8s.node.memory.rss"` + K8sNodeMemoryUsage MetricConfig `mapstructure:"k8s.node.memory.usage"` + K8sNodeMemoryWorkingSet MetricConfig `mapstructure:"k8s.node.memory.working_set"` + K8sNodeNetworkErrors MetricConfig `mapstructure:"k8s.node.network.errors"` + K8sNodeNetworkIo MetricConfig `mapstructure:"k8s.node.network.io"` + K8sPodCPUTime MetricConfig `mapstructure:"k8s.pod.cpu.time"` + K8sPodCPUUtilization MetricConfig `mapstructure:"k8s.pod.cpu.utilization"` + K8sPodFilesystemAvailable MetricConfig `mapstructure:"k8s.pod.filesystem.available"` + K8sPodFilesystemCapacity MetricConfig `mapstructure:"k8s.pod.filesystem.capacity"` + K8sPodFilesystemUsage MetricConfig `mapstructure:"k8s.pod.filesystem.usage"` + K8sPodMemoryAvailable MetricConfig `mapstructure:"k8s.pod.memory.available"` + K8sPodMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.pod.memory.major_page_faults"` + K8sPodMemoryPageFaults MetricConfig `mapstructure:"k8s.pod.memory.page_faults"` + K8sPodMemoryRss MetricConfig `mapstructure:"k8s.pod.memory.rss"` + K8sPodMemoryUsage MetricConfig `mapstructure:"k8s.pod.memory.usage"` + K8sPodMemoryWorkingSet MetricConfig `mapstructure:"k8s.pod.memory.working_set"` + K8sPodNetworkErrors MetricConfig `mapstructure:"k8s.pod.network.errors"` + K8sPodNetworkIo MetricConfig `mapstructure:"k8s.pod.network.io"` + K8sVolumeAvailable MetricConfig `mapstructure:"k8s.volume.available"` + K8sVolumeCapacity MetricConfig `mapstructure:"k8s.volume.capacity"` + K8sVolumeInodes MetricConfig `mapstructure:"k8s.volume.inodes"` + K8sVolumeInodesFree MetricConfig `mapstructure:"k8s.volume.inodes.free"` + K8sVolumeInodesUsed MetricConfig `mapstructure:"k8s.volume.inodes.used"` } func DefaultMetricsConfig() MetricsConfig { @@ -104,6 +115,39 @@ func DefaultMetricsConfig() MetricsConfig { ContainerMemoryWorkingSet: MetricConfig{ Enabled: true, }, + K8sContainerCPUTime: MetricConfig{ + Enabled: false, + }, + K8sContainerCPUUtilization: MetricConfig{ + Enabled: false, + }, + K8sContainerFilesystemAvailable: MetricConfig{ + Enabled: false, + }, + K8sContainerFilesystemCapacity: MetricConfig{ + Enabled: false, + }, + K8sContainerFilesystemUsage: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryAvailable: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryMajorPageFaults: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryPageFaults: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryRss: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryUsage: MetricConfig{ + Enabled: false, + }, + K8sContainerMemoryWorkingSet: MetricConfig{ + Enabled: false, + }, K8sNodeCPUTime: MetricConfig{ Enabled: true, }, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go index bc619d6733de..315c04da8736 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go @@ -26,48 +26,59 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "all_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - ContainerCPUTime: MetricConfig{Enabled: true}, - ContainerCPUUtilization: MetricConfig{Enabled: true}, - ContainerFilesystemAvailable: MetricConfig{Enabled: true}, - ContainerFilesystemCapacity: MetricConfig{Enabled: true}, - ContainerFilesystemUsage: MetricConfig{Enabled: true}, - ContainerMemoryAvailable: MetricConfig{Enabled: true}, - ContainerMemoryMajorPageFaults: MetricConfig{Enabled: true}, - ContainerMemoryPageFaults: MetricConfig{Enabled: true}, - ContainerMemoryRss: MetricConfig{Enabled: true}, - ContainerMemoryUsage: MetricConfig{Enabled: true}, - ContainerMemoryWorkingSet: MetricConfig{Enabled: true}, - K8sNodeCPUTime: MetricConfig{Enabled: true}, - K8sNodeCPUUtilization: MetricConfig{Enabled: true}, - K8sNodeFilesystemAvailable: MetricConfig{Enabled: true}, - K8sNodeFilesystemCapacity: MetricConfig{Enabled: true}, - K8sNodeFilesystemUsage: MetricConfig{Enabled: true}, - K8sNodeMemoryAvailable: MetricConfig{Enabled: true}, - K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: true}, - K8sNodeMemoryPageFaults: MetricConfig{Enabled: true}, - K8sNodeMemoryRss: MetricConfig{Enabled: true}, - K8sNodeMemoryUsage: MetricConfig{Enabled: true}, - K8sNodeMemoryWorkingSet: MetricConfig{Enabled: true}, - K8sNodeNetworkErrors: MetricConfig{Enabled: true}, - K8sNodeNetworkIo: MetricConfig{Enabled: true}, - K8sPodCPUTime: MetricConfig{Enabled: true}, - K8sPodCPUUtilization: MetricConfig{Enabled: true}, - K8sPodFilesystemAvailable: MetricConfig{Enabled: true}, - K8sPodFilesystemCapacity: MetricConfig{Enabled: true}, - K8sPodFilesystemUsage: MetricConfig{Enabled: true}, - K8sPodMemoryAvailable: MetricConfig{Enabled: true}, - K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: true}, - K8sPodMemoryPageFaults: MetricConfig{Enabled: true}, - K8sPodMemoryRss: MetricConfig{Enabled: true}, - K8sPodMemoryUsage: MetricConfig{Enabled: true}, - K8sPodMemoryWorkingSet: MetricConfig{Enabled: true}, - K8sPodNetworkErrors: MetricConfig{Enabled: true}, - K8sPodNetworkIo: MetricConfig{Enabled: true}, - K8sVolumeAvailable: MetricConfig{Enabled: true}, - K8sVolumeCapacity: MetricConfig{Enabled: true}, - K8sVolumeInodes: MetricConfig{Enabled: true}, - K8sVolumeInodesFree: MetricConfig{Enabled: true}, - K8sVolumeInodesUsed: MetricConfig{Enabled: true}, + ContainerCPUTime: MetricConfig{Enabled: true}, + ContainerCPUUtilization: MetricConfig{Enabled: true}, + ContainerFilesystemAvailable: MetricConfig{Enabled: true}, + ContainerFilesystemCapacity: MetricConfig{Enabled: true}, + ContainerFilesystemUsage: MetricConfig{Enabled: true}, + ContainerMemoryAvailable: MetricConfig{Enabled: true}, + ContainerMemoryMajorPageFaults: MetricConfig{Enabled: true}, + ContainerMemoryPageFaults: MetricConfig{Enabled: true}, + ContainerMemoryRss: MetricConfig{Enabled: true}, + ContainerMemoryUsage: MetricConfig{Enabled: true}, + ContainerMemoryWorkingSet: MetricConfig{Enabled: true}, + K8sContainerCPUTime: MetricConfig{Enabled: true}, + K8sContainerCPUUtilization: MetricConfig{Enabled: true}, + K8sContainerFilesystemAvailable: MetricConfig{Enabled: true}, + K8sContainerFilesystemCapacity: MetricConfig{Enabled: true}, + K8sContainerFilesystemUsage: MetricConfig{Enabled: true}, + K8sContainerMemoryAvailable: MetricConfig{Enabled: true}, + K8sContainerMemoryMajorPageFaults: MetricConfig{Enabled: true}, + K8sContainerMemoryPageFaults: MetricConfig{Enabled: true}, + K8sContainerMemoryRss: MetricConfig{Enabled: true}, + K8sContainerMemoryUsage: MetricConfig{Enabled: true}, + K8sContainerMemoryWorkingSet: MetricConfig{Enabled: true}, + K8sNodeCPUTime: MetricConfig{Enabled: true}, + K8sNodeCPUUtilization: MetricConfig{Enabled: true}, + K8sNodeFilesystemAvailable: MetricConfig{Enabled: true}, + K8sNodeFilesystemCapacity: MetricConfig{Enabled: true}, + K8sNodeFilesystemUsage: MetricConfig{Enabled: true}, + K8sNodeMemoryAvailable: MetricConfig{Enabled: true}, + K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: true}, + K8sNodeMemoryPageFaults: MetricConfig{Enabled: true}, + K8sNodeMemoryRss: MetricConfig{Enabled: true}, + K8sNodeMemoryUsage: MetricConfig{Enabled: true}, + K8sNodeMemoryWorkingSet: MetricConfig{Enabled: true}, + K8sNodeNetworkErrors: MetricConfig{Enabled: true}, + K8sNodeNetworkIo: MetricConfig{Enabled: true}, + K8sPodCPUTime: MetricConfig{Enabled: true}, + K8sPodCPUUtilization: MetricConfig{Enabled: true}, + K8sPodFilesystemAvailable: MetricConfig{Enabled: true}, + K8sPodFilesystemCapacity: MetricConfig{Enabled: true}, + K8sPodFilesystemUsage: MetricConfig{Enabled: true}, + K8sPodMemoryAvailable: MetricConfig{Enabled: true}, + K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: true}, + K8sPodMemoryPageFaults: MetricConfig{Enabled: true}, + K8sPodMemoryRss: MetricConfig{Enabled: true}, + K8sPodMemoryUsage: MetricConfig{Enabled: true}, + K8sPodMemoryWorkingSet: MetricConfig{Enabled: true}, + K8sPodNetworkErrors: MetricConfig{Enabled: true}, + K8sPodNetworkIo: MetricConfig{Enabled: true}, + K8sVolumeAvailable: MetricConfig{Enabled: true}, + K8sVolumeCapacity: MetricConfig{Enabled: true}, + K8sVolumeInodes: MetricConfig{Enabled: true}, + K8sVolumeInodesFree: MetricConfig{Enabled: true}, + K8sVolumeInodesUsed: MetricConfig{Enabled: true}, }, ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: true}, @@ -92,48 +103,59 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "none_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - ContainerCPUTime: MetricConfig{Enabled: false}, - ContainerCPUUtilization: MetricConfig{Enabled: false}, - ContainerFilesystemAvailable: MetricConfig{Enabled: false}, - ContainerFilesystemCapacity: MetricConfig{Enabled: false}, - ContainerFilesystemUsage: MetricConfig{Enabled: false}, - ContainerMemoryAvailable: MetricConfig{Enabled: false}, - ContainerMemoryMajorPageFaults: MetricConfig{Enabled: false}, - ContainerMemoryPageFaults: MetricConfig{Enabled: false}, - ContainerMemoryRss: MetricConfig{Enabled: false}, - ContainerMemoryUsage: MetricConfig{Enabled: false}, - ContainerMemoryWorkingSet: MetricConfig{Enabled: false}, - K8sNodeCPUTime: MetricConfig{Enabled: false}, - K8sNodeCPUUtilization: MetricConfig{Enabled: false}, - K8sNodeFilesystemAvailable: MetricConfig{Enabled: false}, - K8sNodeFilesystemCapacity: MetricConfig{Enabled: false}, - K8sNodeFilesystemUsage: MetricConfig{Enabled: false}, - K8sNodeMemoryAvailable: MetricConfig{Enabled: false}, - K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: false}, - K8sNodeMemoryPageFaults: MetricConfig{Enabled: false}, - K8sNodeMemoryRss: MetricConfig{Enabled: false}, - K8sNodeMemoryUsage: MetricConfig{Enabled: false}, - K8sNodeMemoryWorkingSet: MetricConfig{Enabled: false}, - K8sNodeNetworkErrors: MetricConfig{Enabled: false}, - K8sNodeNetworkIo: MetricConfig{Enabled: false}, - K8sPodCPUTime: MetricConfig{Enabled: false}, - K8sPodCPUUtilization: MetricConfig{Enabled: false}, - K8sPodFilesystemAvailable: MetricConfig{Enabled: false}, - K8sPodFilesystemCapacity: MetricConfig{Enabled: false}, - K8sPodFilesystemUsage: MetricConfig{Enabled: false}, - K8sPodMemoryAvailable: MetricConfig{Enabled: false}, - K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: false}, - K8sPodMemoryPageFaults: MetricConfig{Enabled: false}, - K8sPodMemoryRss: MetricConfig{Enabled: false}, - K8sPodMemoryUsage: MetricConfig{Enabled: false}, - K8sPodMemoryWorkingSet: MetricConfig{Enabled: false}, - K8sPodNetworkErrors: MetricConfig{Enabled: false}, - K8sPodNetworkIo: MetricConfig{Enabled: false}, - K8sVolumeAvailable: MetricConfig{Enabled: false}, - K8sVolumeCapacity: MetricConfig{Enabled: false}, - K8sVolumeInodes: MetricConfig{Enabled: false}, - K8sVolumeInodesFree: MetricConfig{Enabled: false}, - K8sVolumeInodesUsed: MetricConfig{Enabled: false}, + ContainerCPUTime: MetricConfig{Enabled: false}, + ContainerCPUUtilization: MetricConfig{Enabled: false}, + ContainerFilesystemAvailable: MetricConfig{Enabled: false}, + ContainerFilesystemCapacity: MetricConfig{Enabled: false}, + ContainerFilesystemUsage: MetricConfig{Enabled: false}, + ContainerMemoryAvailable: MetricConfig{Enabled: false}, + ContainerMemoryMajorPageFaults: MetricConfig{Enabled: false}, + ContainerMemoryPageFaults: MetricConfig{Enabled: false}, + ContainerMemoryRss: MetricConfig{Enabled: false}, + ContainerMemoryUsage: MetricConfig{Enabled: false}, + ContainerMemoryWorkingSet: MetricConfig{Enabled: false}, + K8sContainerCPUTime: MetricConfig{Enabled: false}, + K8sContainerCPUUtilization: MetricConfig{Enabled: false}, + K8sContainerFilesystemAvailable: MetricConfig{Enabled: false}, + K8sContainerFilesystemCapacity: MetricConfig{Enabled: false}, + K8sContainerFilesystemUsage: MetricConfig{Enabled: false}, + K8sContainerMemoryAvailable: MetricConfig{Enabled: false}, + K8sContainerMemoryMajorPageFaults: MetricConfig{Enabled: false}, + K8sContainerMemoryPageFaults: MetricConfig{Enabled: false}, + K8sContainerMemoryRss: MetricConfig{Enabled: false}, + K8sContainerMemoryUsage: MetricConfig{Enabled: false}, + K8sContainerMemoryWorkingSet: MetricConfig{Enabled: false}, + K8sNodeCPUTime: MetricConfig{Enabled: false}, + K8sNodeCPUUtilization: MetricConfig{Enabled: false}, + K8sNodeFilesystemAvailable: MetricConfig{Enabled: false}, + K8sNodeFilesystemCapacity: MetricConfig{Enabled: false}, + K8sNodeFilesystemUsage: MetricConfig{Enabled: false}, + K8sNodeMemoryAvailable: MetricConfig{Enabled: false}, + K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: false}, + K8sNodeMemoryPageFaults: MetricConfig{Enabled: false}, + K8sNodeMemoryRss: MetricConfig{Enabled: false}, + K8sNodeMemoryUsage: MetricConfig{Enabled: false}, + K8sNodeMemoryWorkingSet: MetricConfig{Enabled: false}, + K8sNodeNetworkErrors: MetricConfig{Enabled: false}, + K8sNodeNetworkIo: MetricConfig{Enabled: false}, + K8sPodCPUTime: MetricConfig{Enabled: false}, + K8sPodCPUUtilization: MetricConfig{Enabled: false}, + K8sPodFilesystemAvailable: MetricConfig{Enabled: false}, + K8sPodFilesystemCapacity: MetricConfig{Enabled: false}, + K8sPodFilesystemUsage: MetricConfig{Enabled: false}, + K8sPodMemoryAvailable: MetricConfig{Enabled: false}, + K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: false}, + K8sPodMemoryPageFaults: MetricConfig{Enabled: false}, + K8sPodMemoryRss: MetricConfig{Enabled: false}, + K8sPodMemoryUsage: MetricConfig{Enabled: false}, + K8sPodMemoryWorkingSet: MetricConfig{Enabled: false}, + K8sPodNetworkErrors: MetricConfig{Enabled: false}, + K8sPodNetworkIo: MetricConfig{Enabled: false}, + K8sVolumeAvailable: MetricConfig{Enabled: false}, + K8sVolumeCapacity: MetricConfig{Enabled: false}, + K8sVolumeInodes: MetricConfig{Enabled: false}, + K8sVolumeInodesFree: MetricConfig{Enabled: false}, + K8sVolumeInodesUsed: MetricConfig{Enabled: false}, }, ResourceAttributes: ResourceAttributesConfig{ AwsVolumeID: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go index dd123a5b2fc5..3b10285a8003 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go @@ -46,7 +46,7 @@ type metricContainerCPUTime struct { // init fills container.cpu.time metric with initial data. func (m *metricContainerCPUTime) init() { m.data.SetName("container.cpu.time") - m.data.SetDescription("Container CPU time") + m.data.SetDescription("Deprecated: use `k8s.container.cpu.time` metric instead. Container CPU time") m.data.SetUnit("s") m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(true) @@ -97,7 +97,7 @@ type metricContainerCPUUtilization struct { // init fills container.cpu.utilization metric with initial data. func (m *metricContainerCPUUtilization) init() { m.data.SetName("container.cpu.utilization") - m.data.SetDescription("Container CPU utilization") + m.data.SetDescription("Deprecated: use `k8s.container.cpu.utilization` metric instead. Container CPU utilization") m.data.SetUnit("1") m.data.SetEmptyGauge() } @@ -146,7 +146,7 @@ type metricContainerFilesystemAvailable struct { // init fills container.filesystem.available metric with initial data. func (m *metricContainerFilesystemAvailable) init() { m.data.SetName("container.filesystem.available") - m.data.SetDescription("Container filesystem available") + m.data.SetDescription("Deprecated: use `k8s.container.filesystem.available` metric instead. Container filesystem available") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -195,7 +195,7 @@ type metricContainerFilesystemCapacity struct { // init fills container.filesystem.capacity metric with initial data. func (m *metricContainerFilesystemCapacity) init() { m.data.SetName("container.filesystem.capacity") - m.data.SetDescription("Container filesystem capacity") + m.data.SetDescription("Deprecated: use `k8s.container.filesystem.capacity` metric instead. Container filesystem capacity") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -244,7 +244,7 @@ type metricContainerFilesystemUsage struct { // init fills container.filesystem.usage metric with initial data. func (m *metricContainerFilesystemUsage) init() { m.data.SetName("container.filesystem.usage") - m.data.SetDescription("Container filesystem usage") + m.data.SetDescription("Deprecated: use `k8s.container.filesystem.usage` metric instead. Container filesystem usage") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -293,7 +293,7 @@ type metricContainerMemoryAvailable struct { // init fills container.memory.available metric with initial data. func (m *metricContainerMemoryAvailable) init() { m.data.SetName("container.memory.available") - m.data.SetDescription("Container memory available") + m.data.SetDescription("Deprecated: use `k8s.container.memory.available` metric instead. Container memory available") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -342,7 +342,7 @@ type metricContainerMemoryMajorPageFaults struct { // init fills container.memory.major_page_faults metric with initial data. func (m *metricContainerMemoryMajorPageFaults) init() { m.data.SetName("container.memory.major_page_faults") - m.data.SetDescription("Container memory major_page_faults") + m.data.SetDescription("Deprecated: use `container.memory.major_page_faults` metric instead. Container memory major_page_faults") m.data.SetUnit("1") m.data.SetEmptyGauge() } @@ -391,7 +391,7 @@ type metricContainerMemoryPageFaults struct { // init fills container.memory.page_faults metric with initial data. func (m *metricContainerMemoryPageFaults) init() { m.data.SetName("container.memory.page_faults") - m.data.SetDescription("Container memory page_faults") + m.data.SetDescription("Deprecated: use `k8s.container.memory.page_faults` metric instead. Container memory page_faults") m.data.SetUnit("1") m.data.SetEmptyGauge() } @@ -440,7 +440,7 @@ type metricContainerMemoryRss struct { // init fills container.memory.rss metric with initial data. func (m *metricContainerMemoryRss) init() { m.data.SetName("container.memory.rss") - m.data.SetDescription("Container memory rss") + m.data.SetDescription("Deprecated: use `k8s.container.memory.rss` metric instead. Container memory rss") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -489,7 +489,7 @@ type metricContainerMemoryUsage struct { // init fills container.memory.usage metric with initial data. func (m *metricContainerMemoryUsage) init() { m.data.SetName("container.memory.usage") - m.data.SetDescription("Container memory usage") + m.data.SetDescription("Deprecated: use `k8s.container.memory.usage` metric instead. Container memory usage") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -538,7 +538,7 @@ type metricContainerMemoryWorkingSet struct { // init fills container.memory.working_set metric with initial data. func (m *metricContainerMemoryWorkingSet) init() { m.data.SetName("container.memory.working_set") - m.data.SetDescription("Container memory working_set") + m.data.SetDescription("Deprecated: use `k8s.container.memory.working_set` metric instead. Container memory working_set") m.data.SetUnit("By") m.data.SetEmptyGauge() } @@ -578,6 +578,547 @@ func newMetricContainerMemoryWorkingSet(cfg MetricConfig) metricContainerMemoryW return m } +type metricK8sContainerCPUTime struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.cpu.time metric with initial data. +func (m *metricK8sContainerCPUTime) init() { + m.data.SetName("k8s.container.cpu.time") + m.data.SetDescription("Container CPU time") + m.data.SetUnit("s") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(true) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricK8sContainerCPUTime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetDoubleValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerCPUTime) updateCapacity() { + if m.data.Sum().DataPoints().Len() > m.capacity { + m.capacity = m.data.Sum().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerCPUTime) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerCPUTime(cfg MetricConfig) metricK8sContainerCPUTime { + m := metricK8sContainerCPUTime{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerCPUUtilization struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.cpu.utilization metric with initial data. +func (m *metricK8sContainerCPUUtilization) init() { + m.data.SetName("k8s.container.cpu.utilization") + m.data.SetDescription("Container CPU utilization") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerCPUUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetDoubleValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerCPUUtilization) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerCPUUtilization) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerCPUUtilization(cfg MetricConfig) metricK8sContainerCPUUtilization { + m := metricK8sContainerCPUUtilization{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerFilesystemAvailable struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.filesystem.available metric with initial data. +func (m *metricK8sContainerFilesystemAvailable) init() { + m.data.SetName("k8s.container.filesystem.available") + m.data.SetDescription("Container filesystem available") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerFilesystemAvailable) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerFilesystemAvailable) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerFilesystemAvailable) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerFilesystemAvailable(cfg MetricConfig) metricK8sContainerFilesystemAvailable { + m := metricK8sContainerFilesystemAvailable{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerFilesystemCapacity struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.filesystem.capacity metric with initial data. +func (m *metricK8sContainerFilesystemCapacity) init() { + m.data.SetName("k8s.container.filesystem.capacity") + m.data.SetDescription("Container filesystem capacity") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerFilesystemCapacity) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerFilesystemCapacity) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerFilesystemCapacity) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerFilesystemCapacity(cfg MetricConfig) metricK8sContainerFilesystemCapacity { + m := metricK8sContainerFilesystemCapacity{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerFilesystemUsage struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.filesystem.usage metric with initial data. +func (m *metricK8sContainerFilesystemUsage) init() { + m.data.SetName("k8s.container.filesystem.usage") + m.data.SetDescription("Container filesystem usage") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerFilesystemUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerFilesystemUsage) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerFilesystemUsage) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerFilesystemUsage(cfg MetricConfig) metricK8sContainerFilesystemUsage { + m := metricK8sContainerFilesystemUsage{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryAvailable struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.available metric with initial data. +func (m *metricK8sContainerMemoryAvailable) init() { + m.data.SetName("k8s.container.memory.available") + m.data.SetDescription("Container memory available") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryAvailable) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryAvailable) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryAvailable) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryAvailable(cfg MetricConfig) metricK8sContainerMemoryAvailable { + m := metricK8sContainerMemoryAvailable{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryMajorPageFaults struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.major_page_faults metric with initial data. +func (m *metricK8sContainerMemoryMajorPageFaults) init() { + m.data.SetName("k8s.container.memory.major_page_faults") + m.data.SetDescription("Container memory major_page_faults") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryMajorPageFaults) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryMajorPageFaults) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryMajorPageFaults) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryMajorPageFaults(cfg MetricConfig) metricK8sContainerMemoryMajorPageFaults { + m := metricK8sContainerMemoryMajorPageFaults{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryPageFaults struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.page_faults metric with initial data. +func (m *metricK8sContainerMemoryPageFaults) init() { + m.data.SetName("k8s.container.memory.page_faults") + m.data.SetDescription("Container memory page_faults") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryPageFaults) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryPageFaults) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryPageFaults) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryPageFaults(cfg MetricConfig) metricK8sContainerMemoryPageFaults { + m := metricK8sContainerMemoryPageFaults{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryRss struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.rss metric with initial data. +func (m *metricK8sContainerMemoryRss) init() { + m.data.SetName("k8s.container.memory.rss") + m.data.SetDescription("Container memory rss") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryRss) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryRss) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryRss) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryRss(cfg MetricConfig) metricK8sContainerMemoryRss { + m := metricK8sContainerMemoryRss{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryUsage struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.usage metric with initial data. +func (m *metricK8sContainerMemoryUsage) init() { + m.data.SetName("k8s.container.memory.usage") + m.data.SetDescription("Container memory usage") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryUsage) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryUsage) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryUsage(cfg MetricConfig) metricK8sContainerMemoryUsage { + m := metricK8sContainerMemoryUsage{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + +type metricK8sContainerMemoryWorkingSet struct { + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. +} + +// init fills k8s.container.memory.working_set metric with initial data. +func (m *metricK8sContainerMemoryWorkingSet) init() { + m.data.SetName("k8s.container.memory.working_set") + m.data.SetDescription("Container memory working_set") + m.data.SetUnit("By") + m.data.SetEmptyGauge() +} + +func (m *metricK8sContainerMemoryWorkingSet) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricK8sContainerMemoryWorkingSet) updateCapacity() { + if m.data.Gauge().DataPoints().Len() > m.capacity { + m.capacity = m.data.Gauge().DataPoints().Len() + } +} + +// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. +func (m *metricK8sContainerMemoryWorkingSet) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sContainerMemoryWorkingSet(cfg MetricConfig) metricK8sContainerMemoryWorkingSet { + m := metricK8sContainerMemoryWorkingSet{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricK8sNodeCPUTime struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -2124,54 +2665,65 @@ func newMetricK8sVolumeInodesUsed(cfg MetricConfig) metricK8sVolumeInodesUsed { // MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations // required to produce metric representation defined in metadata and user config. type MetricsBuilder struct { - startTime pcommon.Timestamp // start time that will be applied to all recorded data points. - metricsCapacity int // maximum observed number of metrics per resource. - resourceCapacity int // maximum observed number of resource attributes. - metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. - buildInfo component.BuildInfo // contains version information - resourceAttributesConfig ResourceAttributesConfig - metricContainerCPUTime metricContainerCPUTime - metricContainerCPUUtilization metricContainerCPUUtilization - metricContainerFilesystemAvailable metricContainerFilesystemAvailable - metricContainerFilesystemCapacity metricContainerFilesystemCapacity - metricContainerFilesystemUsage metricContainerFilesystemUsage - metricContainerMemoryAvailable metricContainerMemoryAvailable - metricContainerMemoryMajorPageFaults metricContainerMemoryMajorPageFaults - metricContainerMemoryPageFaults metricContainerMemoryPageFaults - metricContainerMemoryRss metricContainerMemoryRss - metricContainerMemoryUsage metricContainerMemoryUsage - metricContainerMemoryWorkingSet metricContainerMemoryWorkingSet - metricK8sNodeCPUTime metricK8sNodeCPUTime - metricK8sNodeCPUUtilization metricK8sNodeCPUUtilization - metricK8sNodeFilesystemAvailable metricK8sNodeFilesystemAvailable - metricK8sNodeFilesystemCapacity metricK8sNodeFilesystemCapacity - metricK8sNodeFilesystemUsage metricK8sNodeFilesystemUsage - metricK8sNodeMemoryAvailable metricK8sNodeMemoryAvailable - metricK8sNodeMemoryMajorPageFaults metricK8sNodeMemoryMajorPageFaults - metricK8sNodeMemoryPageFaults metricK8sNodeMemoryPageFaults - metricK8sNodeMemoryRss metricK8sNodeMemoryRss - metricK8sNodeMemoryUsage metricK8sNodeMemoryUsage - metricK8sNodeMemoryWorkingSet metricK8sNodeMemoryWorkingSet - metricK8sNodeNetworkErrors metricK8sNodeNetworkErrors - metricK8sNodeNetworkIo metricK8sNodeNetworkIo - metricK8sPodCPUTime metricK8sPodCPUTime - metricK8sPodCPUUtilization metricK8sPodCPUUtilization - metricK8sPodFilesystemAvailable metricK8sPodFilesystemAvailable - metricK8sPodFilesystemCapacity metricK8sPodFilesystemCapacity - metricK8sPodFilesystemUsage metricK8sPodFilesystemUsage - metricK8sPodMemoryAvailable metricK8sPodMemoryAvailable - metricK8sPodMemoryMajorPageFaults metricK8sPodMemoryMajorPageFaults - metricK8sPodMemoryPageFaults metricK8sPodMemoryPageFaults - metricK8sPodMemoryRss metricK8sPodMemoryRss - metricK8sPodMemoryUsage metricK8sPodMemoryUsage - metricK8sPodMemoryWorkingSet metricK8sPodMemoryWorkingSet - metricK8sPodNetworkErrors metricK8sPodNetworkErrors - metricK8sPodNetworkIo metricK8sPodNetworkIo - metricK8sVolumeAvailable metricK8sVolumeAvailable - metricK8sVolumeCapacity metricK8sVolumeCapacity - metricK8sVolumeInodes metricK8sVolumeInodes - metricK8sVolumeInodesFree metricK8sVolumeInodesFree - metricK8sVolumeInodesUsed metricK8sVolumeInodesUsed + startTime pcommon.Timestamp // start time that will be applied to all recorded data points. + metricsCapacity int // maximum observed number of metrics per resource. + resourceCapacity int // maximum observed number of resource attributes. + metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. + buildInfo component.BuildInfo // contains version information + resourceAttributesConfig ResourceAttributesConfig + metricContainerCPUTime metricContainerCPUTime + metricContainerCPUUtilization metricContainerCPUUtilization + metricContainerFilesystemAvailable metricContainerFilesystemAvailable + metricContainerFilesystemCapacity metricContainerFilesystemCapacity + metricContainerFilesystemUsage metricContainerFilesystemUsage + metricContainerMemoryAvailable metricContainerMemoryAvailable + metricContainerMemoryMajorPageFaults metricContainerMemoryMajorPageFaults + metricContainerMemoryPageFaults metricContainerMemoryPageFaults + metricContainerMemoryRss metricContainerMemoryRss + metricContainerMemoryUsage metricContainerMemoryUsage + metricContainerMemoryWorkingSet metricContainerMemoryWorkingSet + metricK8sContainerCPUTime metricK8sContainerCPUTime + metricK8sContainerCPUUtilization metricK8sContainerCPUUtilization + metricK8sContainerFilesystemAvailable metricK8sContainerFilesystemAvailable + metricK8sContainerFilesystemCapacity metricK8sContainerFilesystemCapacity + metricK8sContainerFilesystemUsage metricK8sContainerFilesystemUsage + metricK8sContainerMemoryAvailable metricK8sContainerMemoryAvailable + metricK8sContainerMemoryMajorPageFaults metricK8sContainerMemoryMajorPageFaults + metricK8sContainerMemoryPageFaults metricK8sContainerMemoryPageFaults + metricK8sContainerMemoryRss metricK8sContainerMemoryRss + metricK8sContainerMemoryUsage metricK8sContainerMemoryUsage + metricK8sContainerMemoryWorkingSet metricK8sContainerMemoryWorkingSet + metricK8sNodeCPUTime metricK8sNodeCPUTime + metricK8sNodeCPUUtilization metricK8sNodeCPUUtilization + metricK8sNodeFilesystemAvailable metricK8sNodeFilesystemAvailable + metricK8sNodeFilesystemCapacity metricK8sNodeFilesystemCapacity + metricK8sNodeFilesystemUsage metricK8sNodeFilesystemUsage + metricK8sNodeMemoryAvailable metricK8sNodeMemoryAvailable + metricK8sNodeMemoryMajorPageFaults metricK8sNodeMemoryMajorPageFaults + metricK8sNodeMemoryPageFaults metricK8sNodeMemoryPageFaults + metricK8sNodeMemoryRss metricK8sNodeMemoryRss + metricK8sNodeMemoryUsage metricK8sNodeMemoryUsage + metricK8sNodeMemoryWorkingSet metricK8sNodeMemoryWorkingSet + metricK8sNodeNetworkErrors metricK8sNodeNetworkErrors + metricK8sNodeNetworkIo metricK8sNodeNetworkIo + metricK8sPodCPUTime metricK8sPodCPUTime + metricK8sPodCPUUtilization metricK8sPodCPUUtilization + metricK8sPodFilesystemAvailable metricK8sPodFilesystemAvailable + metricK8sPodFilesystemCapacity metricK8sPodFilesystemCapacity + metricK8sPodFilesystemUsage metricK8sPodFilesystemUsage + metricK8sPodMemoryAvailable metricK8sPodMemoryAvailable + metricK8sPodMemoryMajorPageFaults metricK8sPodMemoryMajorPageFaults + metricK8sPodMemoryPageFaults metricK8sPodMemoryPageFaults + metricK8sPodMemoryRss metricK8sPodMemoryRss + metricK8sPodMemoryUsage metricK8sPodMemoryUsage + metricK8sPodMemoryWorkingSet metricK8sPodMemoryWorkingSet + metricK8sPodNetworkErrors metricK8sPodNetworkErrors + metricK8sPodNetworkIo metricK8sPodNetworkIo + metricK8sVolumeAvailable metricK8sVolumeAvailable + metricK8sVolumeCapacity metricK8sVolumeCapacity + metricK8sVolumeInodes metricK8sVolumeInodes + metricK8sVolumeInodesFree metricK8sVolumeInodesFree + metricK8sVolumeInodesUsed metricK8sVolumeInodesUsed } // metricBuilderOption applies changes to default metrics builder. @@ -2185,53 +2737,97 @@ func WithStartTime(startTime pcommon.Timestamp) metricBuilderOption { } func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSettings, options ...metricBuilderOption) *MetricsBuilder { + if mbc.Metrics.ContainerCPUTime.Enabled { + settings.Logger.Warn("[WARNING] `container.cpu.time` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerCPUUtilization.Enabled { + settings.Logger.Warn("[WARNING] `container.cpu.utilization` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerFilesystemAvailable.Enabled { + settings.Logger.Warn("[WARNING] `container.filesystem.available` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerFilesystemCapacity.Enabled { + settings.Logger.Warn("[WARNING] `container.filesystem.capacity` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerFilesystemUsage.Enabled { + settings.Logger.Warn("[WARNING] `container.filesystem.usage` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryAvailable.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.available` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryMajorPageFaults.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.major_page_faults` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryPageFaults.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.page_faults` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryRss.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.rss` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryUsage.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.usage` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } + if mbc.Metrics.ContainerMemoryWorkingSet.Enabled { + settings.Logger.Warn("[WARNING] `container.memory.working_set` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.") + } mb := &MetricsBuilder{ - startTime: pcommon.NewTimestampFromTime(time.Now()), - metricsBuffer: pmetric.NewMetrics(), - buildInfo: settings.BuildInfo, - resourceAttributesConfig: mbc.ResourceAttributes, - metricContainerCPUTime: newMetricContainerCPUTime(mbc.Metrics.ContainerCPUTime), - metricContainerCPUUtilization: newMetricContainerCPUUtilization(mbc.Metrics.ContainerCPUUtilization), - metricContainerFilesystemAvailable: newMetricContainerFilesystemAvailable(mbc.Metrics.ContainerFilesystemAvailable), - metricContainerFilesystemCapacity: newMetricContainerFilesystemCapacity(mbc.Metrics.ContainerFilesystemCapacity), - metricContainerFilesystemUsage: newMetricContainerFilesystemUsage(mbc.Metrics.ContainerFilesystemUsage), - metricContainerMemoryAvailable: newMetricContainerMemoryAvailable(mbc.Metrics.ContainerMemoryAvailable), - metricContainerMemoryMajorPageFaults: newMetricContainerMemoryMajorPageFaults(mbc.Metrics.ContainerMemoryMajorPageFaults), - metricContainerMemoryPageFaults: newMetricContainerMemoryPageFaults(mbc.Metrics.ContainerMemoryPageFaults), - metricContainerMemoryRss: newMetricContainerMemoryRss(mbc.Metrics.ContainerMemoryRss), - metricContainerMemoryUsage: newMetricContainerMemoryUsage(mbc.Metrics.ContainerMemoryUsage), - metricContainerMemoryWorkingSet: newMetricContainerMemoryWorkingSet(mbc.Metrics.ContainerMemoryWorkingSet), - metricK8sNodeCPUTime: newMetricK8sNodeCPUTime(mbc.Metrics.K8sNodeCPUTime), - metricK8sNodeCPUUtilization: newMetricK8sNodeCPUUtilization(mbc.Metrics.K8sNodeCPUUtilization), - metricK8sNodeFilesystemAvailable: newMetricK8sNodeFilesystemAvailable(mbc.Metrics.K8sNodeFilesystemAvailable), - metricK8sNodeFilesystemCapacity: newMetricK8sNodeFilesystemCapacity(mbc.Metrics.K8sNodeFilesystemCapacity), - metricK8sNodeFilesystemUsage: newMetricK8sNodeFilesystemUsage(mbc.Metrics.K8sNodeFilesystemUsage), - metricK8sNodeMemoryAvailable: newMetricK8sNodeMemoryAvailable(mbc.Metrics.K8sNodeMemoryAvailable), - metricK8sNodeMemoryMajorPageFaults: newMetricK8sNodeMemoryMajorPageFaults(mbc.Metrics.K8sNodeMemoryMajorPageFaults), - metricK8sNodeMemoryPageFaults: newMetricK8sNodeMemoryPageFaults(mbc.Metrics.K8sNodeMemoryPageFaults), - metricK8sNodeMemoryRss: newMetricK8sNodeMemoryRss(mbc.Metrics.K8sNodeMemoryRss), - metricK8sNodeMemoryUsage: newMetricK8sNodeMemoryUsage(mbc.Metrics.K8sNodeMemoryUsage), - metricK8sNodeMemoryWorkingSet: newMetricK8sNodeMemoryWorkingSet(mbc.Metrics.K8sNodeMemoryWorkingSet), - metricK8sNodeNetworkErrors: newMetricK8sNodeNetworkErrors(mbc.Metrics.K8sNodeNetworkErrors), - metricK8sNodeNetworkIo: newMetricK8sNodeNetworkIo(mbc.Metrics.K8sNodeNetworkIo), - metricK8sPodCPUTime: newMetricK8sPodCPUTime(mbc.Metrics.K8sPodCPUTime), - metricK8sPodCPUUtilization: newMetricK8sPodCPUUtilization(mbc.Metrics.K8sPodCPUUtilization), - metricK8sPodFilesystemAvailable: newMetricK8sPodFilesystemAvailable(mbc.Metrics.K8sPodFilesystemAvailable), - metricK8sPodFilesystemCapacity: newMetricK8sPodFilesystemCapacity(mbc.Metrics.K8sPodFilesystemCapacity), - metricK8sPodFilesystemUsage: newMetricK8sPodFilesystemUsage(mbc.Metrics.K8sPodFilesystemUsage), - metricK8sPodMemoryAvailable: newMetricK8sPodMemoryAvailable(mbc.Metrics.K8sPodMemoryAvailable), - metricK8sPodMemoryMajorPageFaults: newMetricK8sPodMemoryMajorPageFaults(mbc.Metrics.K8sPodMemoryMajorPageFaults), - metricK8sPodMemoryPageFaults: newMetricK8sPodMemoryPageFaults(mbc.Metrics.K8sPodMemoryPageFaults), - metricK8sPodMemoryRss: newMetricK8sPodMemoryRss(mbc.Metrics.K8sPodMemoryRss), - metricK8sPodMemoryUsage: newMetricK8sPodMemoryUsage(mbc.Metrics.K8sPodMemoryUsage), - metricK8sPodMemoryWorkingSet: newMetricK8sPodMemoryWorkingSet(mbc.Metrics.K8sPodMemoryWorkingSet), - metricK8sPodNetworkErrors: newMetricK8sPodNetworkErrors(mbc.Metrics.K8sPodNetworkErrors), - metricK8sPodNetworkIo: newMetricK8sPodNetworkIo(mbc.Metrics.K8sPodNetworkIo), - metricK8sVolumeAvailable: newMetricK8sVolumeAvailable(mbc.Metrics.K8sVolumeAvailable), - metricK8sVolumeCapacity: newMetricK8sVolumeCapacity(mbc.Metrics.K8sVolumeCapacity), - metricK8sVolumeInodes: newMetricK8sVolumeInodes(mbc.Metrics.K8sVolumeInodes), - metricK8sVolumeInodesFree: newMetricK8sVolumeInodesFree(mbc.Metrics.K8sVolumeInodesFree), - metricK8sVolumeInodesUsed: newMetricK8sVolumeInodesUsed(mbc.Metrics.K8sVolumeInodesUsed), + startTime: pcommon.NewTimestampFromTime(time.Now()), + metricsBuffer: pmetric.NewMetrics(), + buildInfo: settings.BuildInfo, + resourceAttributesConfig: mbc.ResourceAttributes, + metricContainerCPUTime: newMetricContainerCPUTime(mbc.Metrics.ContainerCPUTime), + metricContainerCPUUtilization: newMetricContainerCPUUtilization(mbc.Metrics.ContainerCPUUtilization), + metricContainerFilesystemAvailable: newMetricContainerFilesystemAvailable(mbc.Metrics.ContainerFilesystemAvailable), + metricContainerFilesystemCapacity: newMetricContainerFilesystemCapacity(mbc.Metrics.ContainerFilesystemCapacity), + metricContainerFilesystemUsage: newMetricContainerFilesystemUsage(mbc.Metrics.ContainerFilesystemUsage), + metricContainerMemoryAvailable: newMetricContainerMemoryAvailable(mbc.Metrics.ContainerMemoryAvailable), + metricContainerMemoryMajorPageFaults: newMetricContainerMemoryMajorPageFaults(mbc.Metrics.ContainerMemoryMajorPageFaults), + metricContainerMemoryPageFaults: newMetricContainerMemoryPageFaults(mbc.Metrics.ContainerMemoryPageFaults), + metricContainerMemoryRss: newMetricContainerMemoryRss(mbc.Metrics.ContainerMemoryRss), + metricContainerMemoryUsage: newMetricContainerMemoryUsage(mbc.Metrics.ContainerMemoryUsage), + metricContainerMemoryWorkingSet: newMetricContainerMemoryWorkingSet(mbc.Metrics.ContainerMemoryWorkingSet), + metricK8sContainerCPUTime: newMetricK8sContainerCPUTime(mbc.Metrics.K8sContainerCPUTime), + metricK8sContainerCPUUtilization: newMetricK8sContainerCPUUtilization(mbc.Metrics.K8sContainerCPUUtilization), + metricK8sContainerFilesystemAvailable: newMetricK8sContainerFilesystemAvailable(mbc.Metrics.K8sContainerFilesystemAvailable), + metricK8sContainerFilesystemCapacity: newMetricK8sContainerFilesystemCapacity(mbc.Metrics.K8sContainerFilesystemCapacity), + metricK8sContainerFilesystemUsage: newMetricK8sContainerFilesystemUsage(mbc.Metrics.K8sContainerFilesystemUsage), + metricK8sContainerMemoryAvailable: newMetricK8sContainerMemoryAvailable(mbc.Metrics.K8sContainerMemoryAvailable), + metricK8sContainerMemoryMajorPageFaults: newMetricK8sContainerMemoryMajorPageFaults(mbc.Metrics.K8sContainerMemoryMajorPageFaults), + metricK8sContainerMemoryPageFaults: newMetricK8sContainerMemoryPageFaults(mbc.Metrics.K8sContainerMemoryPageFaults), + metricK8sContainerMemoryRss: newMetricK8sContainerMemoryRss(mbc.Metrics.K8sContainerMemoryRss), + metricK8sContainerMemoryUsage: newMetricK8sContainerMemoryUsage(mbc.Metrics.K8sContainerMemoryUsage), + metricK8sContainerMemoryWorkingSet: newMetricK8sContainerMemoryWorkingSet(mbc.Metrics.K8sContainerMemoryWorkingSet), + metricK8sNodeCPUTime: newMetricK8sNodeCPUTime(mbc.Metrics.K8sNodeCPUTime), + metricK8sNodeCPUUtilization: newMetricK8sNodeCPUUtilization(mbc.Metrics.K8sNodeCPUUtilization), + metricK8sNodeFilesystemAvailable: newMetricK8sNodeFilesystemAvailable(mbc.Metrics.K8sNodeFilesystemAvailable), + metricK8sNodeFilesystemCapacity: newMetricK8sNodeFilesystemCapacity(mbc.Metrics.K8sNodeFilesystemCapacity), + metricK8sNodeFilesystemUsage: newMetricK8sNodeFilesystemUsage(mbc.Metrics.K8sNodeFilesystemUsage), + metricK8sNodeMemoryAvailable: newMetricK8sNodeMemoryAvailable(mbc.Metrics.K8sNodeMemoryAvailable), + metricK8sNodeMemoryMajorPageFaults: newMetricK8sNodeMemoryMajorPageFaults(mbc.Metrics.K8sNodeMemoryMajorPageFaults), + metricK8sNodeMemoryPageFaults: newMetricK8sNodeMemoryPageFaults(mbc.Metrics.K8sNodeMemoryPageFaults), + metricK8sNodeMemoryRss: newMetricK8sNodeMemoryRss(mbc.Metrics.K8sNodeMemoryRss), + metricK8sNodeMemoryUsage: newMetricK8sNodeMemoryUsage(mbc.Metrics.K8sNodeMemoryUsage), + metricK8sNodeMemoryWorkingSet: newMetricK8sNodeMemoryWorkingSet(mbc.Metrics.K8sNodeMemoryWorkingSet), + metricK8sNodeNetworkErrors: newMetricK8sNodeNetworkErrors(mbc.Metrics.K8sNodeNetworkErrors), + metricK8sNodeNetworkIo: newMetricK8sNodeNetworkIo(mbc.Metrics.K8sNodeNetworkIo), + metricK8sPodCPUTime: newMetricK8sPodCPUTime(mbc.Metrics.K8sPodCPUTime), + metricK8sPodCPUUtilization: newMetricK8sPodCPUUtilization(mbc.Metrics.K8sPodCPUUtilization), + metricK8sPodFilesystemAvailable: newMetricK8sPodFilesystemAvailable(mbc.Metrics.K8sPodFilesystemAvailable), + metricK8sPodFilesystemCapacity: newMetricK8sPodFilesystemCapacity(mbc.Metrics.K8sPodFilesystemCapacity), + metricK8sPodFilesystemUsage: newMetricK8sPodFilesystemUsage(mbc.Metrics.K8sPodFilesystemUsage), + metricK8sPodMemoryAvailable: newMetricK8sPodMemoryAvailable(mbc.Metrics.K8sPodMemoryAvailable), + metricK8sPodMemoryMajorPageFaults: newMetricK8sPodMemoryMajorPageFaults(mbc.Metrics.K8sPodMemoryMajorPageFaults), + metricK8sPodMemoryPageFaults: newMetricK8sPodMemoryPageFaults(mbc.Metrics.K8sPodMemoryPageFaults), + metricK8sPodMemoryRss: newMetricK8sPodMemoryRss(mbc.Metrics.K8sPodMemoryRss), + metricK8sPodMemoryUsage: newMetricK8sPodMemoryUsage(mbc.Metrics.K8sPodMemoryUsage), + metricK8sPodMemoryWorkingSet: newMetricK8sPodMemoryWorkingSet(mbc.Metrics.K8sPodMemoryWorkingSet), + metricK8sPodNetworkErrors: newMetricK8sPodNetworkErrors(mbc.Metrics.K8sPodNetworkErrors), + metricK8sPodNetworkIo: newMetricK8sPodNetworkIo(mbc.Metrics.K8sPodNetworkIo), + metricK8sVolumeAvailable: newMetricK8sVolumeAvailable(mbc.Metrics.K8sVolumeAvailable), + metricK8sVolumeCapacity: newMetricK8sVolumeCapacity(mbc.Metrics.K8sVolumeCapacity), + metricK8sVolumeInodes: newMetricK8sVolumeInodes(mbc.Metrics.K8sVolumeInodes), + metricK8sVolumeInodesFree: newMetricK8sVolumeInodesFree(mbc.Metrics.K8sVolumeInodesFree), + metricK8sVolumeInodesUsed: newMetricK8sVolumeInodesUsed(mbc.Metrics.K8sVolumeInodesUsed), } for _, op := range options { op(mb) @@ -2430,6 +3026,17 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricContainerMemoryRss.emit(ils.Metrics()) mb.metricContainerMemoryUsage.emit(ils.Metrics()) mb.metricContainerMemoryWorkingSet.emit(ils.Metrics()) + mb.metricK8sContainerCPUTime.emit(ils.Metrics()) + mb.metricK8sContainerCPUUtilization.emit(ils.Metrics()) + mb.metricK8sContainerFilesystemAvailable.emit(ils.Metrics()) + mb.metricK8sContainerFilesystemCapacity.emit(ils.Metrics()) + mb.metricK8sContainerFilesystemUsage.emit(ils.Metrics()) + mb.metricK8sContainerMemoryAvailable.emit(ils.Metrics()) + mb.metricK8sContainerMemoryMajorPageFaults.emit(ils.Metrics()) + mb.metricK8sContainerMemoryPageFaults.emit(ils.Metrics()) + mb.metricK8sContainerMemoryRss.emit(ils.Metrics()) + mb.metricK8sContainerMemoryUsage.emit(ils.Metrics()) + mb.metricK8sContainerMemoryWorkingSet.emit(ils.Metrics()) mb.metricK8sNodeCPUTime.emit(ils.Metrics()) mb.metricK8sNodeCPUUtilization.emit(ils.Metrics()) mb.metricK8sNodeFilesystemAvailable.emit(ils.Metrics()) @@ -2536,6 +3143,61 @@ func (mb *MetricsBuilder) RecordContainerMemoryWorkingSetDataPoint(ts pcommon.Ti mb.metricContainerMemoryWorkingSet.recordDataPoint(mb.startTime, ts, val) } +// RecordK8sContainerCPUTimeDataPoint adds a data point to k8s.container.cpu.time metric. +func (mb *MetricsBuilder) RecordK8sContainerCPUTimeDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricK8sContainerCPUTime.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerCPUUtilizationDataPoint adds a data point to k8s.container.cpu.utilization metric. +func (mb *MetricsBuilder) RecordK8sContainerCPUUtilizationDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricK8sContainerCPUUtilization.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerFilesystemAvailableDataPoint adds a data point to k8s.container.filesystem.available metric. +func (mb *MetricsBuilder) RecordK8sContainerFilesystemAvailableDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerFilesystemAvailable.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerFilesystemCapacityDataPoint adds a data point to k8s.container.filesystem.capacity metric. +func (mb *MetricsBuilder) RecordK8sContainerFilesystemCapacityDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerFilesystemCapacity.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerFilesystemUsageDataPoint adds a data point to k8s.container.filesystem.usage metric. +func (mb *MetricsBuilder) RecordK8sContainerFilesystemUsageDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerFilesystemUsage.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryAvailableDataPoint adds a data point to k8s.container.memory.available metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryAvailableDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryAvailable.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryMajorPageFaultsDataPoint adds a data point to k8s.container.memory.major_page_faults metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryMajorPageFaultsDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryMajorPageFaults.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryPageFaultsDataPoint adds a data point to k8s.container.memory.page_faults metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryPageFaultsDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryPageFaults.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryRssDataPoint adds a data point to k8s.container.memory.rss metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryRssDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryRss.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryUsageDataPoint adds a data point to k8s.container.memory.usage metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryUsageDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryUsage.recordDataPoint(mb.startTime, ts, val) +} + +// RecordK8sContainerMemoryWorkingSetDataPoint adds a data point to k8s.container.memory.working_set metric. +func (mb *MetricsBuilder) RecordK8sContainerMemoryWorkingSetDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricK8sContainerMemoryWorkingSet.recordDataPoint(mb.startTime, ts, val) +} + // RecordK8sNodeCPUTimeDataPoint adds a data point to k8s.node.cpu.time metric. func (mb *MetricsBuilder) RecordK8sNodeCPUTimeDataPoint(ts pcommon.Timestamp, val float64) { mb.metricK8sNodeCPUTime.recordDataPoint(mb.startTime, ts, val) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go index af9bd759c490..9da37eb2118b 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go @@ -49,6 +49,50 @@ func TestMetricsBuilder(t *testing.T) { mb := NewMetricsBuilder(loadMetricsBuilderConfig(t, test.name), settings, WithStartTime(start)) expectedWarnings := 0 + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.cpu.time` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.cpu.utilization` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.filesystem.available` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.filesystem.capacity` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.filesystem.usage` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.available` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.major_page_faults` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.page_faults` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.rss` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.usage` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } + if test.configSet == testSetDefault || test.configSet == testSetAll { + assert.Equal(t, "[WARNING] `container.memory.working_set` should not be enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0.", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } assert.Equal(t, expectedWarnings, observedLogs.Len()) defaultMetricsCount := 0 @@ -98,6 +142,39 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordContainerMemoryWorkingSetDataPoint(ts, 1) + allMetricsCount++ + mb.RecordK8sContainerCPUTimeDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerCPUUtilizationDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerFilesystemAvailableDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerFilesystemCapacityDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerFilesystemUsageDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryAvailableDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryMajorPageFaultsDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryPageFaultsDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryRssDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryUsageDataPoint(ts, 1) + + allMetricsCount++ + mb.RecordK8sContainerMemoryWorkingSetDataPoint(ts, 1) + defaultMetricsCount++ allMetricsCount++ mb.RecordK8sNodeCPUTimeDataPoint(ts, 1) @@ -357,7 +434,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.cpu.time"] = true assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "Container CPU time", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.cpu.time` metric instead. Container CPU time", ms.At(i).Description()) assert.Equal(t, "s", ms.At(i).Unit()) assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) @@ -371,7 +448,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.cpu.utilization"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container CPU utilization", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.cpu.utilization` metric instead. Container CPU utilization", ms.At(i).Description()) assert.Equal(t, "1", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -383,7 +460,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.filesystem.available"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container filesystem available", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.filesystem.available` metric instead. Container filesystem available", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -395,7 +472,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.filesystem.capacity"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container filesystem capacity", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.filesystem.capacity` metric instead. Container filesystem capacity", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -407,7 +484,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.filesystem.usage"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container filesystem usage", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.filesystem.usage` metric instead. Container filesystem usage", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -419,7 +496,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.available"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container memory available", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.memory.available` metric instead. Container memory available", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -431,7 +508,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.major_page_faults"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container memory major_page_faults", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `container.memory.major_page_faults` metric instead. Container memory major_page_faults", ms.At(i).Description()) assert.Equal(t, "1", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -443,7 +520,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.page_faults"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container memory page_faults", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.memory.page_faults` metric instead. Container memory page_faults", ms.At(i).Description()) assert.Equal(t, "1", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -455,7 +532,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.rss"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container memory rss", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.memory.rss` metric instead. Container memory rss", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -467,7 +544,7 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.usage"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Container memory usage", ms.At(i).Description()) + assert.Equal(t, "Deprecated: use `k8s.container.memory.usage` metric instead. Container memory usage", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) assert.Equal(t, start, dp.StartTimestamp()) @@ -479,6 +556,140 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics["container.memory.working_set"] = true assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Deprecated: use `k8s.container.memory.working_set` metric instead. Container memory working_set", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.cpu.time": + assert.False(t, validatedMetrics["k8s.container.cpu.time"], "Found a duplicate in the metrics slice: k8s.container.cpu.time") + validatedMetrics["k8s.container.cpu.time"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Container CPU time", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + assert.Equal(t, true, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + case "k8s.container.cpu.utilization": + assert.False(t, validatedMetrics["k8s.container.cpu.utilization"], "Found a duplicate in the metrics slice: k8s.container.cpu.utilization") + validatedMetrics["k8s.container.cpu.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container CPU utilization", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + case "k8s.container.filesystem.available": + assert.False(t, validatedMetrics["k8s.container.filesystem.available"], "Found a duplicate in the metrics slice: k8s.container.filesystem.available") + validatedMetrics["k8s.container.filesystem.available"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container filesystem available", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.filesystem.capacity": + assert.False(t, validatedMetrics["k8s.container.filesystem.capacity"], "Found a duplicate in the metrics slice: k8s.container.filesystem.capacity") + validatedMetrics["k8s.container.filesystem.capacity"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container filesystem capacity", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.filesystem.usage": + assert.False(t, validatedMetrics["k8s.container.filesystem.usage"], "Found a duplicate in the metrics slice: k8s.container.filesystem.usage") + validatedMetrics["k8s.container.filesystem.usage"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container filesystem usage", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.available": + assert.False(t, validatedMetrics["k8s.container.memory.available"], "Found a duplicate in the metrics slice: k8s.container.memory.available") + validatedMetrics["k8s.container.memory.available"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container memory available", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.major_page_faults": + assert.False(t, validatedMetrics["k8s.container.memory.major_page_faults"], "Found a duplicate in the metrics slice: k8s.container.memory.major_page_faults") + validatedMetrics["k8s.container.memory.major_page_faults"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container memory major_page_faults", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.page_faults": + assert.False(t, validatedMetrics["k8s.container.memory.page_faults"], "Found a duplicate in the metrics slice: k8s.container.memory.page_faults") + validatedMetrics["k8s.container.memory.page_faults"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container memory page_faults", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.rss": + assert.False(t, validatedMetrics["k8s.container.memory.rss"], "Found a duplicate in the metrics slice: k8s.container.memory.rss") + validatedMetrics["k8s.container.memory.rss"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container memory rss", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.usage": + assert.False(t, validatedMetrics["k8s.container.memory.usage"], "Found a duplicate in the metrics slice: k8s.container.memory.usage") + validatedMetrics["k8s.container.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Container memory usage", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "k8s.container.memory.working_set": + assert.False(t, validatedMetrics["k8s.container.memory.working_set"], "Found a duplicate in the metrics slice: k8s.container.memory.working_set") + validatedMetrics["k8s.container.memory.working_set"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) assert.Equal(t, "Container memory working_set", ms.At(i).Description()) assert.Equal(t, "By", ms.At(i).Unit()) dp := ms.At(i).Gauge().DataPoints().At(0) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/metrics.go index c95dfe8f9451..7bc4a23d77a2 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/metrics.go @@ -19,83 +19,83 @@ type MetricsBuilders struct { } type CPUMetrics struct { - Time RecordDoubleDataPointFunc - Utilization RecordDoubleDataPointFunc + Time []RecordDoubleDataPointFunc + Utilization []RecordDoubleDataPointFunc } var NodeCPUMetrics = CPUMetrics{ - Time: (*MetricsBuilder).RecordK8sNodeCPUTimeDataPoint, - Utilization: (*MetricsBuilder).RecordK8sNodeCPUUtilizationDataPoint, + Time: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordK8sNodeCPUTimeDataPoint}, + Utilization: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordK8sNodeCPUUtilizationDataPoint}, } var PodCPUMetrics = CPUMetrics{ - Time: (*MetricsBuilder).RecordK8sPodCPUTimeDataPoint, - Utilization: (*MetricsBuilder).RecordK8sPodCPUUtilizationDataPoint, + Time: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordK8sPodCPUTimeDataPoint}, + Utilization: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordK8sPodCPUUtilizationDataPoint}, } var ContainerCPUMetrics = CPUMetrics{ - Time: (*MetricsBuilder).RecordContainerCPUTimeDataPoint, - Utilization: (*MetricsBuilder).RecordContainerCPUUtilizationDataPoint, + Time: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordContainerCPUTimeDataPoint, (*MetricsBuilder).RecordK8sContainerCPUTimeDataPoint}, + Utilization: []RecordDoubleDataPointFunc{(*MetricsBuilder).RecordContainerCPUUtilizationDataPoint, (*MetricsBuilder).RecordK8sContainerCPUUtilizationDataPoint}, } type MemoryMetrics struct { - Available RecordIntDataPointFunc - Usage RecordIntDataPointFunc - Rss RecordIntDataPointFunc - WorkingSet RecordIntDataPointFunc - PageFaults RecordIntDataPointFunc - MajorPageFaults RecordIntDataPointFunc + Available []RecordIntDataPointFunc + Usage []RecordIntDataPointFunc + Rss []RecordIntDataPointFunc + WorkingSet []RecordIntDataPointFunc + PageFaults []RecordIntDataPointFunc + MajorPageFaults []RecordIntDataPointFunc } var NodeMemoryMetrics = MemoryMetrics{ - Available: (*MetricsBuilder).RecordK8sNodeMemoryAvailableDataPoint, - Usage: (*MetricsBuilder).RecordK8sNodeMemoryUsageDataPoint, - Rss: (*MetricsBuilder).RecordK8sNodeMemoryRssDataPoint, - WorkingSet: (*MetricsBuilder).RecordK8sNodeMemoryWorkingSetDataPoint, - PageFaults: (*MetricsBuilder).RecordK8sNodeMemoryPageFaultsDataPoint, - MajorPageFaults: (*MetricsBuilder).RecordK8sNodeMemoryMajorPageFaultsDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryAvailableDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryUsageDataPoint}, + Rss: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryRssDataPoint}, + WorkingSet: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryWorkingSetDataPoint}, + PageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryPageFaultsDataPoint}, + MajorPageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeMemoryMajorPageFaultsDataPoint}, } var PodMemoryMetrics = MemoryMetrics{ - Available: (*MetricsBuilder).RecordK8sPodMemoryAvailableDataPoint, - Usage: (*MetricsBuilder).RecordK8sPodMemoryUsageDataPoint, - Rss: (*MetricsBuilder).RecordK8sPodMemoryRssDataPoint, - WorkingSet: (*MetricsBuilder).RecordK8sPodMemoryWorkingSetDataPoint, - PageFaults: (*MetricsBuilder).RecordK8sPodMemoryPageFaultsDataPoint, - MajorPageFaults: (*MetricsBuilder).RecordK8sPodMemoryMajorPageFaultsDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryAvailableDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryUsageDataPoint}, + Rss: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryRssDataPoint}, + WorkingSet: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryWorkingSetDataPoint}, + PageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryPageFaultsDataPoint}, + MajorPageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodMemoryMajorPageFaultsDataPoint}, } var ContainerMemoryMetrics = MemoryMetrics{ - Available: (*MetricsBuilder).RecordContainerMemoryAvailableDataPoint, - Usage: (*MetricsBuilder).RecordContainerMemoryUsageDataPoint, - Rss: (*MetricsBuilder).RecordContainerMemoryRssDataPoint, - WorkingSet: (*MetricsBuilder).RecordContainerMemoryWorkingSetDataPoint, - PageFaults: (*MetricsBuilder).RecordContainerMemoryPageFaultsDataPoint, - MajorPageFaults: (*MetricsBuilder).RecordContainerMemoryMajorPageFaultsDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryAvailableDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryAvailableDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryUsageDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryUsageDataPoint}, + Rss: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryRssDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryRssDataPoint}, + WorkingSet: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryWorkingSetDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryWorkingSetDataPoint}, + PageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryPageFaultsDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryPageFaultsDataPoint}, + MajorPageFaults: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerMemoryMajorPageFaultsDataPoint, (*MetricsBuilder).RecordK8sContainerMemoryMajorPageFaultsDataPoint}, } type FilesystemMetrics struct { - Available RecordIntDataPointFunc - Capacity RecordIntDataPointFunc - Usage RecordIntDataPointFunc + Available []RecordIntDataPointFunc + Capacity []RecordIntDataPointFunc + Usage []RecordIntDataPointFunc } var NodeFilesystemMetrics = FilesystemMetrics{ - Available: (*MetricsBuilder).RecordK8sNodeFilesystemAvailableDataPoint, - Capacity: (*MetricsBuilder).RecordK8sNodeFilesystemCapacityDataPoint, - Usage: (*MetricsBuilder).RecordK8sNodeFilesystemUsageDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeFilesystemAvailableDataPoint}, + Capacity: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeFilesystemCapacityDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sNodeFilesystemUsageDataPoint}, } var PodFilesystemMetrics = FilesystemMetrics{ - Available: (*MetricsBuilder).RecordK8sPodFilesystemAvailableDataPoint, - Capacity: (*MetricsBuilder).RecordK8sPodFilesystemCapacityDataPoint, - Usage: (*MetricsBuilder).RecordK8sPodFilesystemUsageDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodFilesystemAvailableDataPoint}, + Capacity: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodFilesystemCapacityDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordK8sPodFilesystemUsageDataPoint}, } var ContainerFilesystemMetrics = FilesystemMetrics{ - Available: (*MetricsBuilder).RecordContainerFilesystemAvailableDataPoint, - Capacity: (*MetricsBuilder).RecordContainerFilesystemCapacityDataPoint, - Usage: (*MetricsBuilder).RecordContainerFilesystemUsageDataPoint, + Available: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerFilesystemAvailableDataPoint, (*MetricsBuilder).RecordK8sContainerFilesystemAvailableDataPoint}, + Capacity: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerFilesystemCapacityDataPoint, (*MetricsBuilder).RecordK8sContainerFilesystemCapacityDataPoint}, + Usage: []RecordIntDataPointFunc{(*MetricsBuilder).RecordContainerFilesystemUsageDataPoint, (*MetricsBuilder).RecordK8sContainerFilesystemUsageDataPoint}, } type NetworkMetrics struct { diff --git a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml index bd960d239a07..ee22591339d3 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/kubeletstatsreceiver/internal/metadata/testdata/config.yaml @@ -23,6 +23,28 @@ all_set: enabled: true container.memory.working_set: enabled: true + k8s.container.cpu.time: + enabled: true + k8s.container.cpu.utilization: + enabled: true + k8s.container.filesystem.available: + enabled: true + k8s.container.filesystem.capacity: + enabled: true + k8s.container.filesystem.usage: + enabled: true + k8s.container.memory.available: + enabled: true + k8s.container.memory.major_page_faults: + enabled: true + k8s.container.memory.page_faults: + enabled: true + k8s.container.memory.rss: + enabled: true + k8s.container.memory.usage: + enabled: true + k8s.container.memory.working_set: + enabled: true k8s.node.cpu.time: enabled: true k8s.node.cpu.utilization: @@ -140,6 +162,28 @@ none_set: enabled: false container.memory.working_set: enabled: false + k8s.container.cpu.time: + enabled: false + k8s.container.cpu.utilization: + enabled: false + k8s.container.filesystem.available: + enabled: false + k8s.container.filesystem.capacity: + enabled: false + k8s.container.filesystem.usage: + enabled: false + k8s.container.memory.available: + enabled: false + k8s.container.memory.major_page_faults: + enabled: false + k8s.container.memory.page_faults: + enabled: false + k8s.container.memory.rss: + enabled: false + k8s.container.memory.usage: + enabled: false + k8s.container.memory.working_set: + enabled: false k8s.node.cpu.time: enabled: false k8s.node.cpu.utilization: diff --git a/receiver/kubeletstatsreceiver/metadata.yaml b/receiver/kubeletstatsreceiver/metadata.yaml index 6b5249229caf..d5ec8d0fb756 100644 --- a/receiver/kubeletstatsreceiver/metadata.yaml +++ b/receiver/kubeletstatsreceiver/metadata.yaml @@ -275,6 +275,15 @@ metrics: attributes: ["interface", "direction"] container.cpu.utilization: enabled: true + description: "Deprecated: use `k8s.container.cpu.utilization` metric instead. Container CPU utilization" + unit: 1 + gauge: + value_type: double + attributes: [ ] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.cpu.utilization: + enabled: false description: "Container CPU utilization" unit: 1 gauge: @@ -282,6 +291,17 @@ metrics: attributes: [ ] container.cpu.time: enabled: true + description: "Deprecated: use `k8s.container.cpu.time` metric instead. Container CPU time" + unit: s + sum: + value_type: double + monotonic: true + aggregation: cumulative + attributes: [ ] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.cpu.time: + enabled: false description: "Container CPU time" unit: s sum: @@ -291,6 +311,15 @@ metrics: attributes: [ ] container.memory.available: enabled: true + description: "Deprecated: use `k8s.container.memory.available` metric instead. Container memory available" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.available: + enabled: false description: "Container memory available" unit: By gauge: @@ -298,6 +327,15 @@ metrics: attributes: [] container.memory.usage: enabled: true + description: "Deprecated: use `k8s.container.memory.usage` metric instead. Container memory usage" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.usage: + enabled: false description: "Container memory usage" unit: By gauge: @@ -305,6 +343,15 @@ metrics: attributes: [] container.memory.rss: enabled: true + description: "Deprecated: use `k8s.container.memory.rss` metric instead. Container memory rss" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.rss: + enabled: false description: "Container memory rss" unit: By gauge: @@ -312,6 +359,15 @@ metrics: attributes: [] container.memory.working_set: enabled: true + description: "Deprecated: use `k8s.container.memory.working_set` metric instead. Container memory working_set" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.working_set: + enabled: false description: "Container memory working_set" unit: By gauge: @@ -319,6 +375,15 @@ metrics: attributes: [] container.memory.page_faults: enabled: true + description: "Deprecated: use `k8s.container.memory.page_faults` metric instead. Container memory page_faults" + unit: 1 + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.page_faults: + enabled: false description: "Container memory page_faults" unit: 1 gauge: @@ -326,6 +391,15 @@ metrics: attributes: [] container.memory.major_page_faults: enabled: true + description: "Deprecated: use `container.memory.major_page_faults` metric instead. Container memory major_page_faults" + unit: 1 + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.memory.major_page_faults: + enabled: false description: "Container memory major_page_faults" unit: 1 gauge: @@ -333,6 +407,15 @@ metrics: attributes: [] container.filesystem.available: enabled: true + description: "Deprecated: use `k8s.container.filesystem.available` metric instead. Container filesystem available" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.filesystem.available: + enabled: false description: "Container filesystem available" unit: By gauge: @@ -340,6 +423,15 @@ metrics: attributes: [] container.filesystem.capacity: enabled: true + description: "Deprecated: use `k8s.container.filesystem.capacity` metric instead. Container filesystem capacity" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.filesystem.capacity: + enabled: false description: "Container filesystem capacity" unit: By gauge: @@ -347,6 +439,15 @@ metrics: attributes: [] container.filesystem.usage: enabled: true + description: "Deprecated: use `k8s.container.filesystem.usage` metric instead. Container filesystem usage" + unit: By + gauge: + value_type: int + attributes: [] + warnings: + if_enabled: This metric will be disabled in v0.84.0 and removed in v0.86.0. + k8s.container.filesystem.usage: + enabled: false description: "Container filesystem usage" unit: By gauge: