diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go index fc60dd040e76..2522cee29a24 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config.go @@ -30,6 +30,7 @@ type MetricsConfig struct { ContainerFilesystemAvailable MetricConfig `mapstructure:"container.filesystem.available"` ContainerFilesystemCapacity MetricConfig `mapstructure:"container.filesystem.capacity"` ContainerFilesystemUsage MetricConfig `mapstructure:"container.filesystem.usage"` + ContainerFilesystemUtilization MetricConfig `mapstructure:"container.filesystem.utilization"` ContainerMemoryAvailable MetricConfig `mapstructure:"container.memory.available"` ContainerMemoryMajorPageFaults MetricConfig `mapstructure:"container.memory.major_page_faults"` ContainerMemoryPageFaults MetricConfig `mapstructure:"container.memory.page_faults"` @@ -46,6 +47,7 @@ type MetricsConfig struct { K8sNodeFilesystemAvailable MetricConfig `mapstructure:"k8s.node.filesystem.available"` K8sNodeFilesystemCapacity MetricConfig `mapstructure:"k8s.node.filesystem.capacity"` K8sNodeFilesystemUsage MetricConfig `mapstructure:"k8s.node.filesystem.usage"` + K8sNodeFilesystemUtilization MetricConfig `mapstructure:"k8s.node.filesystem.utilization"` K8sNodeMemoryAvailable MetricConfig `mapstructure:"k8s.node.memory.available"` K8sNodeMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.node.memory.major_page_faults"` K8sNodeMemoryPageFaults MetricConfig `mapstructure:"k8s.node.memory.page_faults"` @@ -62,6 +64,7 @@ type MetricsConfig struct { K8sPodFilesystemAvailable MetricConfig `mapstructure:"k8s.pod.filesystem.available"` K8sPodFilesystemCapacity MetricConfig `mapstructure:"k8s.pod.filesystem.capacity"` K8sPodFilesystemUsage MetricConfig `mapstructure:"k8s.pod.filesystem.usage"` + K8sPodFilesystemUtilization MetricConfig `mapstructure:"k8s.pod.filesystem.utilization"` K8sPodMemoryAvailable MetricConfig `mapstructure:"k8s.pod.memory.available"` K8sPodMemoryMajorPageFaults MetricConfig `mapstructure:"k8s.pod.memory.major_page_faults"` K8sPodMemoryPageFaults MetricConfig `mapstructure:"k8s.pod.memory.page_faults"` @@ -97,6 +100,9 @@ func DefaultMetricsConfig() MetricsConfig { ContainerFilesystemUsage: MetricConfig{ Enabled: true, }, + ContainerFilesystemUtilization: MetricConfig{ + Enabled: true, + }, ContainerMemoryAvailable: MetricConfig{ Enabled: true, }, @@ -145,6 +151,9 @@ func DefaultMetricsConfig() MetricsConfig { K8sNodeFilesystemUsage: MetricConfig{ Enabled: true, }, + K8sNodeFilesystemUtilization: MetricConfig{ + Enabled: true, + }, K8sNodeMemoryAvailable: MetricConfig{ Enabled: true, }, @@ -193,6 +202,9 @@ func DefaultMetricsConfig() MetricsConfig { K8sPodFilesystemUsage: MetricConfig{ Enabled: true, }, + K8sPodFilesystemUtilization: MetricConfig{ + Enabled: true, + }, K8sPodMemoryAvailable: MetricConfig{ Enabled: true, }, @@ -247,20 +259,6 @@ func DefaultMetricsConfig() MetricsConfig { // ResourceAttributeConfig provides common config for a particular resource attribute. type ResourceAttributeConfig struct { Enabled bool `mapstructure:"enabled"` - - enabledSetByUser bool -} - -func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { - if parser == nil { - return nil - } - err := parser.Unmarshal(rac, confmap.WithErrorUnused()) - if err != nil { - return err - } - rac.enabledSetByUser = parser.IsSet("enabled") - return nil } // ResourceAttributesConfig provides config for kubeletstats resource attributes. @@ -273,12 +271,15 @@ type ResourceAttributesConfig struct { GlusterfsPath ResourceAttributeConfig `mapstructure:"glusterfs.path"` K8sClusterName ResourceAttributeConfig `mapstructure:"k8s.cluster.name"` K8sContainerName ResourceAttributeConfig `mapstructure:"k8s.container.name"` + K8sJobName ResourceAttributeConfig `mapstructure:"k8s.job.name"` + K8sJobUID ResourceAttributeConfig `mapstructure:"k8s.job.uid"` K8sNamespaceName ResourceAttributeConfig `mapstructure:"k8s.namespace.name"` K8sNodeName ResourceAttributeConfig `mapstructure:"k8s.node.name"` K8sNodeStartTime ResourceAttributeConfig `mapstructure:"k8s.node.start_time"` K8sNodeUID ResourceAttributeConfig `mapstructure:"k8s.node.uid"` K8sPersistentvolumeclaimName ResourceAttributeConfig `mapstructure:"k8s.persistentvolumeclaim.name"` K8sPodName ResourceAttributeConfig `mapstructure:"k8s.pod.name"` + K8sPodStartTime ResourceAttributeConfig `mapstructure:"k8s.pod.start_time"` K8sPodUID ResourceAttributeConfig `mapstructure:"k8s.pod.uid"` K8sServiceName ResourceAttributeConfig `mapstructure:"k8s.service.name"` K8sServiceAccountName ResourceAttributeConfig `mapstructure:"k8s.service_account.name"` @@ -313,6 +314,12 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sContainerName: ResourceAttributeConfig{ Enabled: true, }, + K8sJobName: ResourceAttributeConfig{ + Enabled: true, + }, + K8sJobUID: ResourceAttributeConfig{ + Enabled: true, + }, K8sNamespaceName: ResourceAttributeConfig{ Enabled: true, }, @@ -331,6 +338,9 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sPodName: ResourceAttributeConfig{ Enabled: true, }, + K8sPodStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sPodUID: ResourceAttributeConfig{ Enabled: true, }, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go index 2581f618e18b..5592038b730d 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_config_test.go @@ -31,6 +31,7 @@ func TestMetricsBuilderConfig(t *testing.T) { ContainerFilesystemAvailable: MetricConfig{Enabled: true}, ContainerFilesystemCapacity: MetricConfig{Enabled: true}, ContainerFilesystemUsage: MetricConfig{Enabled: true}, + ContainerFilesystemUtilization: MetricConfig{Enabled: true}, ContainerMemoryAvailable: MetricConfig{Enabled: true}, ContainerMemoryMajorPageFaults: MetricConfig{Enabled: true}, ContainerMemoryPageFaults: MetricConfig{Enabled: true}, @@ -47,6 +48,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sNodeFilesystemAvailable: MetricConfig{Enabled: true}, K8sNodeFilesystemCapacity: MetricConfig{Enabled: true}, K8sNodeFilesystemUsage: MetricConfig{Enabled: true}, + K8sNodeFilesystemUtilization: MetricConfig{Enabled: true}, K8sNodeMemoryAvailable: MetricConfig{Enabled: true}, K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: true}, K8sNodeMemoryPageFaults: MetricConfig{Enabled: true}, @@ -63,6 +65,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sPodFilesystemAvailable: MetricConfig{Enabled: true}, K8sPodFilesystemCapacity: MetricConfig{Enabled: true}, K8sPodFilesystemUsage: MetricConfig{Enabled: true}, + K8sPodFilesystemUtilization: MetricConfig{Enabled: true}, K8sPodMemoryAvailable: MetricConfig{Enabled: true}, K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: true}, K8sPodMemoryPageFaults: MetricConfig{Enabled: true}, @@ -89,12 +92,15 @@ func TestMetricsBuilderConfig(t *testing.T) { GlusterfsPath: ResourceAttributeConfig{Enabled: true}, K8sClusterName: ResourceAttributeConfig{Enabled: true}, K8sContainerName: ResourceAttributeConfig{Enabled: true}, + K8sJobName: ResourceAttributeConfig{Enabled: true}, + K8sJobUID: ResourceAttributeConfig{Enabled: true}, K8sNamespaceName: ResourceAttributeConfig{Enabled: true}, K8sNodeName: ResourceAttributeConfig{Enabled: true}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: true}, K8sNodeUID: ResourceAttributeConfig{Enabled: true}, K8sPersistentvolumeclaimName: ResourceAttributeConfig{Enabled: true}, K8sPodName: ResourceAttributeConfig{Enabled: true}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: true}, K8sPodUID: ResourceAttributeConfig{Enabled: true}, K8sServiceName: ResourceAttributeConfig{Enabled: true}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: true}, @@ -113,6 +119,7 @@ func TestMetricsBuilderConfig(t *testing.T) { ContainerFilesystemAvailable: MetricConfig{Enabled: false}, ContainerFilesystemCapacity: MetricConfig{Enabled: false}, ContainerFilesystemUsage: MetricConfig{Enabled: false}, + ContainerFilesystemUtilization: MetricConfig{Enabled: false}, ContainerMemoryAvailable: MetricConfig{Enabled: false}, ContainerMemoryMajorPageFaults: MetricConfig{Enabled: false}, ContainerMemoryPageFaults: MetricConfig{Enabled: false}, @@ -129,6 +136,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sNodeFilesystemAvailable: MetricConfig{Enabled: false}, K8sNodeFilesystemCapacity: MetricConfig{Enabled: false}, K8sNodeFilesystemUsage: MetricConfig{Enabled: false}, + K8sNodeFilesystemUtilization: MetricConfig{Enabled: false}, K8sNodeMemoryAvailable: MetricConfig{Enabled: false}, K8sNodeMemoryMajorPageFaults: MetricConfig{Enabled: false}, K8sNodeMemoryPageFaults: MetricConfig{Enabled: false}, @@ -145,6 +153,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sPodFilesystemAvailable: MetricConfig{Enabled: false}, K8sPodFilesystemCapacity: MetricConfig{Enabled: false}, K8sPodFilesystemUsage: MetricConfig{Enabled: false}, + K8sPodFilesystemUtilization: MetricConfig{Enabled: false}, K8sPodMemoryAvailable: MetricConfig{Enabled: false}, K8sPodMemoryMajorPageFaults: MetricConfig{Enabled: false}, K8sPodMemoryPageFaults: MetricConfig{Enabled: false}, @@ -171,12 +180,15 @@ func TestMetricsBuilderConfig(t *testing.T) { GlusterfsPath: ResourceAttributeConfig{Enabled: false}, K8sClusterName: ResourceAttributeConfig{Enabled: false}, K8sContainerName: ResourceAttributeConfig{Enabled: false}, + K8sJobName: ResourceAttributeConfig{Enabled: false}, + K8sJobUID: ResourceAttributeConfig{Enabled: false}, K8sNamespaceName: ResourceAttributeConfig{Enabled: false}, K8sNodeName: ResourceAttributeConfig{Enabled: false}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: false}, K8sNodeUID: ResourceAttributeConfig{Enabled: false}, K8sPersistentvolumeclaimName: ResourceAttributeConfig{Enabled: false}, K8sPodName: ResourceAttributeConfig{Enabled: false}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: false}, K8sPodUID: ResourceAttributeConfig{Enabled: false}, K8sServiceName: ResourceAttributeConfig{Enabled: false}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: false}, @@ -227,12 +239,15 @@ func TestResourceAttributesConfig(t *testing.T) { GlusterfsPath: ResourceAttributeConfig{Enabled: true}, K8sClusterName: ResourceAttributeConfig{Enabled: true}, K8sContainerName: ResourceAttributeConfig{Enabled: true}, + K8sJobName: ResourceAttributeConfig{Enabled: true}, + K8sJobUID: ResourceAttributeConfig{Enabled: true}, K8sNamespaceName: ResourceAttributeConfig{Enabled: true}, K8sNodeName: ResourceAttributeConfig{Enabled: true}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: true}, K8sNodeUID: ResourceAttributeConfig{Enabled: true}, K8sPersistentvolumeclaimName: ResourceAttributeConfig{Enabled: true}, K8sPodName: ResourceAttributeConfig{Enabled: true}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: true}, K8sPodUID: ResourceAttributeConfig{Enabled: true}, K8sServiceName: ResourceAttributeConfig{Enabled: true}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: true}, @@ -252,12 +267,15 @@ func TestResourceAttributesConfig(t *testing.T) { GlusterfsPath: ResourceAttributeConfig{Enabled: false}, K8sClusterName: ResourceAttributeConfig{Enabled: false}, K8sContainerName: ResourceAttributeConfig{Enabled: false}, + K8sJobName: ResourceAttributeConfig{Enabled: false}, + K8sJobUID: ResourceAttributeConfig{Enabled: false}, K8sNamespaceName: ResourceAttributeConfig{Enabled: false}, K8sNodeName: ResourceAttributeConfig{Enabled: false}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: false}, K8sNodeUID: ResourceAttributeConfig{Enabled: false}, K8sPersistentvolumeclaimName: ResourceAttributeConfig{Enabled: false}, K8sPodName: ResourceAttributeConfig{Enabled: false}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: false}, K8sPodUID: ResourceAttributeConfig{Enabled: false}, K8sServiceName: ResourceAttributeConfig{Enabled: false}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go index 03f94dc800bf..785187a49a79 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go @@ -284,6 +284,55 @@ func newMetricContainerFilesystemUsage(cfg MetricConfig) metricContainerFilesyst return m } +type metricContainerFilesystemUtilization 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 container.filesystem.utilization metric with initial data. +func (m *metricContainerFilesystemUtilization) init() { + m.data.SetName("container.filesystem.utilization") + m.data.SetDescription("Container filesystem utilization") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricContainerFilesystemUtilization) 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 *metricContainerFilesystemUtilization) 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 *metricContainerFilesystemUtilization) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricContainerFilesystemUtilization(cfg MetricConfig) metricContainerFilesystemUtilization { + m := metricContainerFilesystemUtilization{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricContainerMemoryAvailable struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -1072,6 +1121,55 @@ func newMetricK8sNodeFilesystemUsage(cfg MetricConfig) metricK8sNodeFilesystemUs return m } +type metricK8sNodeFilesystemUtilization 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.node.filesystem.utilization metric with initial data. +func (m *metricK8sNodeFilesystemUtilization) init() { + m.data.SetName("k8s.node.filesystem.utilization") + m.data.SetDescription("Node filesystem utilization") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricK8sNodeFilesystemUtilization) 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 *metricK8sNodeFilesystemUtilization) 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 *metricK8sNodeFilesystemUtilization) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sNodeFilesystemUtilization(cfg MetricConfig) metricK8sNodeFilesystemUtilization { + m := metricK8sNodeFilesystemUtilization{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricK8sNodeMemoryAvailable struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -1870,6 +1968,55 @@ func newMetricK8sPodFilesystemUsage(cfg MetricConfig) metricK8sPodFilesystemUsag return m } +type metricK8sPodFilesystemUtilization 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.pod.filesystem.utilization metric with initial data. +func (m *metricK8sPodFilesystemUtilization) init() { + m.data.SetName("k8s.pod.filesystem.utilization") + m.data.SetDescription("Pod filesystem utilization") + m.data.SetUnit("1") + m.data.SetEmptyGauge() +} + +func (m *metricK8sPodFilesystemUtilization) 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 *metricK8sPodFilesystemUtilization) 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 *metricK8sPodFilesystemUtilization) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricK8sPodFilesystemUtilization(cfg MetricConfig) metricK8sPodFilesystemUtilization { + m := metricK8sPodFilesystemUtilization{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricK8sPodMemoryAvailable struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -2679,6 +2826,7 @@ type MetricsBuilder struct { metricContainerFilesystemAvailable metricContainerFilesystemAvailable metricContainerFilesystemCapacity metricContainerFilesystemCapacity metricContainerFilesystemUsage metricContainerFilesystemUsage + metricContainerFilesystemUtilization metricContainerFilesystemUtilization metricContainerMemoryAvailable metricContainerMemoryAvailable metricContainerMemoryMajorPageFaults metricContainerMemoryMajorPageFaults metricContainerMemoryPageFaults metricContainerMemoryPageFaults @@ -2695,6 +2843,7 @@ type MetricsBuilder struct { metricK8sNodeFilesystemAvailable metricK8sNodeFilesystemAvailable metricK8sNodeFilesystemCapacity metricK8sNodeFilesystemCapacity metricK8sNodeFilesystemUsage metricK8sNodeFilesystemUsage + metricK8sNodeFilesystemUtilization metricK8sNodeFilesystemUtilization metricK8sNodeMemoryAvailable metricK8sNodeMemoryAvailable metricK8sNodeMemoryMajorPageFaults metricK8sNodeMemoryMajorPageFaults metricK8sNodeMemoryPageFaults metricK8sNodeMemoryPageFaults @@ -2711,6 +2860,7 @@ type MetricsBuilder struct { metricK8sPodFilesystemAvailable metricK8sPodFilesystemAvailable metricK8sPodFilesystemCapacity metricK8sPodFilesystemCapacity metricK8sPodFilesystemUsage metricK8sPodFilesystemUsage + metricK8sPodFilesystemUtilization metricK8sPodFilesystemUtilization metricK8sPodMemoryAvailable metricK8sPodMemoryAvailable metricK8sPodMemoryMajorPageFaults metricK8sPodMemoryMajorPageFaults metricK8sPodMemoryPageFaults metricK8sPodMemoryPageFaults @@ -2750,6 +2900,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting metricContainerFilesystemAvailable: newMetricContainerFilesystemAvailable(mbc.Metrics.ContainerFilesystemAvailable), metricContainerFilesystemCapacity: newMetricContainerFilesystemCapacity(mbc.Metrics.ContainerFilesystemCapacity), metricContainerFilesystemUsage: newMetricContainerFilesystemUsage(mbc.Metrics.ContainerFilesystemUsage), + metricContainerFilesystemUtilization: newMetricContainerFilesystemUtilization(mbc.Metrics.ContainerFilesystemUtilization), metricContainerMemoryAvailable: newMetricContainerMemoryAvailable(mbc.Metrics.ContainerMemoryAvailable), metricContainerMemoryMajorPageFaults: newMetricContainerMemoryMajorPageFaults(mbc.Metrics.ContainerMemoryMajorPageFaults), metricContainerMemoryPageFaults: newMetricContainerMemoryPageFaults(mbc.Metrics.ContainerMemoryPageFaults), @@ -2766,6 +2917,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting metricK8sNodeFilesystemAvailable: newMetricK8sNodeFilesystemAvailable(mbc.Metrics.K8sNodeFilesystemAvailable), metricK8sNodeFilesystemCapacity: newMetricK8sNodeFilesystemCapacity(mbc.Metrics.K8sNodeFilesystemCapacity), metricK8sNodeFilesystemUsage: newMetricK8sNodeFilesystemUsage(mbc.Metrics.K8sNodeFilesystemUsage), + metricK8sNodeFilesystemUtilization: newMetricK8sNodeFilesystemUtilization(mbc.Metrics.K8sNodeFilesystemUtilization), metricK8sNodeMemoryAvailable: newMetricK8sNodeMemoryAvailable(mbc.Metrics.K8sNodeMemoryAvailable), metricK8sNodeMemoryMajorPageFaults: newMetricK8sNodeMemoryMajorPageFaults(mbc.Metrics.K8sNodeMemoryMajorPageFaults), metricK8sNodeMemoryPageFaults: newMetricK8sNodeMemoryPageFaults(mbc.Metrics.K8sNodeMemoryPageFaults), @@ -2782,6 +2934,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting metricK8sPodFilesystemAvailable: newMetricK8sPodFilesystemAvailable(mbc.Metrics.K8sPodFilesystemAvailable), metricK8sPodFilesystemCapacity: newMetricK8sPodFilesystemCapacity(mbc.Metrics.K8sPodFilesystemCapacity), metricK8sPodFilesystemUsage: newMetricK8sPodFilesystemUsage(mbc.Metrics.K8sPodFilesystemUsage), + metricK8sPodFilesystemUtilization: newMetricK8sPodFilesystemUtilization(mbc.Metrics.K8sPodFilesystemUtilization), metricK8sPodMemoryAvailable: newMetricK8sPodMemoryAvailable(mbc.Metrics.K8sPodMemoryAvailable), metricK8sPodMemoryMajorPageFaults: newMetricK8sPodMemoryMajorPageFaults(mbc.Metrics.K8sPodMemoryMajorPageFaults), metricK8sPodMemoryPageFaults: newMetricK8sPodMemoryPageFaults(mbc.Metrics.K8sPodMemoryPageFaults), @@ -2864,6 +3017,7 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricContainerFilesystemAvailable.emit(ils.Metrics()) mb.metricContainerFilesystemCapacity.emit(ils.Metrics()) mb.metricContainerFilesystemUsage.emit(ils.Metrics()) + mb.metricContainerFilesystemUtilization.emit(ils.Metrics()) mb.metricContainerMemoryAvailable.emit(ils.Metrics()) mb.metricContainerMemoryMajorPageFaults.emit(ils.Metrics()) mb.metricContainerMemoryPageFaults.emit(ils.Metrics()) @@ -2880,6 +3034,7 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricK8sNodeFilesystemAvailable.emit(ils.Metrics()) mb.metricK8sNodeFilesystemCapacity.emit(ils.Metrics()) mb.metricK8sNodeFilesystemUsage.emit(ils.Metrics()) + mb.metricK8sNodeFilesystemUtilization.emit(ils.Metrics()) mb.metricK8sNodeMemoryAvailable.emit(ils.Metrics()) mb.metricK8sNodeMemoryMajorPageFaults.emit(ils.Metrics()) mb.metricK8sNodeMemoryPageFaults.emit(ils.Metrics()) @@ -2896,6 +3051,7 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricK8sPodFilesystemAvailable.emit(ils.Metrics()) mb.metricK8sPodFilesystemCapacity.emit(ils.Metrics()) mb.metricK8sPodFilesystemUsage.emit(ils.Metrics()) + mb.metricK8sPodFilesystemUtilization.emit(ils.Metrics()) mb.metricK8sPodMemoryAvailable.emit(ils.Metrics()) mb.metricK8sPodMemoryMajorPageFaults.emit(ils.Metrics()) mb.metricK8sPodMemoryPageFaults.emit(ils.Metrics()) @@ -2957,6 +3113,11 @@ func (mb *MetricsBuilder) RecordContainerFilesystemUsageDataPoint(ts pcommon.Tim mb.metricContainerFilesystemUsage.recordDataPoint(mb.startTime, ts, val) } +// RecordContainerFilesystemUtilizationDataPoint adds a data point to container.filesystem.utilization metric. +func (mb *MetricsBuilder) RecordContainerFilesystemUtilizationDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricContainerFilesystemUtilization.recordDataPoint(mb.startTime, ts, val) +} + // RecordContainerMemoryAvailableDataPoint adds a data point to container.memory.available metric. func (mb *MetricsBuilder) RecordContainerMemoryAvailableDataPoint(ts pcommon.Timestamp, val int64) { mb.metricContainerMemoryAvailable.recordDataPoint(mb.startTime, ts, val) @@ -3037,6 +3198,11 @@ func (mb *MetricsBuilder) RecordK8sNodeFilesystemUsageDataPoint(ts pcommon.Times mb.metricK8sNodeFilesystemUsage.recordDataPoint(mb.startTime, ts, val) } +// RecordK8sNodeFilesystemUtilizationDataPoint adds a data point to k8s.node.filesystem.utilization metric. +func (mb *MetricsBuilder) RecordK8sNodeFilesystemUtilizationDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricK8sNodeFilesystemUtilization.recordDataPoint(mb.startTime, ts, val) +} + // RecordK8sNodeMemoryAvailableDataPoint adds a data point to k8s.node.memory.available metric. func (mb *MetricsBuilder) RecordK8sNodeMemoryAvailableDataPoint(ts pcommon.Timestamp, val int64) { mb.metricK8sNodeMemoryAvailable.recordDataPoint(mb.startTime, ts, val) @@ -3117,6 +3283,11 @@ func (mb *MetricsBuilder) RecordK8sPodFilesystemUsageDataPoint(ts pcommon.Timest mb.metricK8sPodFilesystemUsage.recordDataPoint(mb.startTime, ts, val) } +// RecordK8sPodFilesystemUtilizationDataPoint adds a data point to k8s.pod.filesystem.utilization metric. +func (mb *MetricsBuilder) RecordK8sPodFilesystemUtilizationDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricK8sPodFilesystemUtilization.recordDataPoint(mb.startTime, ts, val) +} + // RecordK8sPodMemoryAvailableDataPoint adds a data point to k8s.pod.memory.available metric. func (mb *MetricsBuilder) RecordK8sPodMemoryAvailableDataPoint(ts pcommon.Timestamp, val int64) { mb.metricK8sPodMemoryAvailable.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 4b5076ff3908..fe3feca86c1d 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go @@ -49,7 +49,6 @@ func TestMetricsBuilder(t *testing.T) { mb := NewMetricsBuilder(loadMetricsBuilderConfig(t, test.name), settings, WithStartTime(start)) expectedWarnings := 0 - assert.Equal(t, expectedWarnings, observedLogs.Len()) defaultMetricsCount := 0 diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go index 69c4917f6879..464c8e8a8707 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_status.go @@ -4,19 +4,9 @@ package metadata import ( "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/trace" ) const ( Type = "kubeletstats" MetricsStability = component.StabilityLevelBeta ) - -func Meter(settings component.TelemetrySettings) metric.Meter { - return settings.MeterProvider.Meter("otelcol/kubeletstatsreceiver") -} - -func Tracer(settings component.TelemetrySettings) trace.Tracer { - return settings.TracerProvider.Tracer("otelcol/kubeletstatsreceiver") -}