diff --git a/.chloggen/add-two-new-vecenter-receiver-metrics.yaml b/.chloggen/add-two-new-vecenter-receiver-metrics.yaml new file mode 100644 index 000000000000..835bf9b0eb51 --- /dev/null +++ b/.chloggen/add-two-new-vecenter-receiver-metrics.yaml @@ -0,0 +1,21 @@ +# Use this changelog template to create an entry for release notes. +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: vcenterreceiver +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Adds vCenter memory capacity for hosts and memory granted metric for VMs." +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [37257] +# (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: +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/receiver/vcenterreceiver/documentation.md b/receiver/vcenterreceiver/documentation.md index b94da9b4c931..5657f5ed3531 100644 --- a/receiver/vcenterreceiver/documentation.md +++ b/receiver/vcenterreceiver/documentation.md @@ -802,6 +802,32 @@ The vSAN throughput of a virtual machine. | ---- | ----------- | ------ | | direction | The type of vSAN throughput. | Str: ``read``, ``write`` | +## 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 +``` + +### vcenter.host.memory.capacity + +Total memory capacity of the host system. + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| MiBy | Sum | Double | Cumulative | false | + +### vcenter.vm.memory.granted + +The amount of memory that is granted to a VM. + +| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | +| ---- | ----------- | ---------- | ----------------------- | --------- | +| MiBy | Sum | Int | Cumulative | false | + ## Resource Attributes | Name | Description | Values | Enabled | diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config.go b/receiver/vcenterreceiver/internal/metadata/generated_config.go index fed73e8bfda7..dd875d38847a 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config.go @@ -55,6 +55,7 @@ type MetricsConfig struct { VcenterHostDiskLatencyAvg MetricConfig `mapstructure:"vcenter.host.disk.latency.avg"` VcenterHostDiskLatencyMax MetricConfig `mapstructure:"vcenter.host.disk.latency.max"` VcenterHostDiskThroughput MetricConfig `mapstructure:"vcenter.host.disk.throughput"` + VcenterHostMemoryCapacity MetricConfig `mapstructure:"vcenter.host.memory.capacity"` VcenterHostMemoryUsage MetricConfig `mapstructure:"vcenter.host.memory.usage"` VcenterHostMemoryUtilization MetricConfig `mapstructure:"vcenter.host.memory.utilization"` VcenterHostNetworkPacketDropRate MetricConfig `mapstructure:"vcenter.host.network.packet.drop.rate"` @@ -83,6 +84,7 @@ type MetricsConfig struct { VcenterVMDiskUsage MetricConfig `mapstructure:"vcenter.vm.disk.usage"` VcenterVMDiskUtilization MetricConfig `mapstructure:"vcenter.vm.disk.utilization"` VcenterVMMemoryBallooned MetricConfig `mapstructure:"vcenter.vm.memory.ballooned"` + VcenterVMMemoryGranted MetricConfig `mapstructure:"vcenter.vm.memory.granted"` VcenterVMMemorySwapped MetricConfig `mapstructure:"vcenter.vm.memory.swapped"` VcenterVMMemorySwappedSsd MetricConfig `mapstructure:"vcenter.vm.memory.swapped_ssd"` VcenterVMMemoryUsage MetricConfig `mapstructure:"vcenter.vm.memory.usage"` @@ -179,6 +181,9 @@ func DefaultMetricsConfig() MetricsConfig { VcenterHostDiskThroughput: MetricConfig{ Enabled: true, }, + VcenterHostMemoryCapacity: MetricConfig{ + Enabled: false, + }, VcenterHostMemoryUsage: MetricConfig{ Enabled: true, }, @@ -263,6 +268,9 @@ func DefaultMetricsConfig() MetricsConfig { VcenterVMMemoryBallooned: MetricConfig{ Enabled: true, }, + VcenterVMMemoryGranted: MetricConfig{ + Enabled: false, + }, VcenterVMMemorySwapped: MetricConfig{ Enabled: true, }, diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go index 0f377aed38c7..66cf8d162b10 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go @@ -52,6 +52,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterHostDiskLatencyAvg: MetricConfig{Enabled: true}, VcenterHostDiskLatencyMax: MetricConfig{Enabled: true}, VcenterHostDiskThroughput: MetricConfig{Enabled: true}, + VcenterHostMemoryCapacity: MetricConfig{Enabled: true}, VcenterHostMemoryUsage: MetricConfig{Enabled: true}, VcenterHostMemoryUtilization: MetricConfig{Enabled: true}, VcenterHostNetworkPacketDropRate: MetricConfig{Enabled: true}, @@ -80,6 +81,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterVMDiskUsage: MetricConfig{Enabled: true}, VcenterVMDiskUtilization: MetricConfig{Enabled: true}, VcenterVMMemoryBallooned: MetricConfig{Enabled: true}, + VcenterVMMemoryGranted: MetricConfig{Enabled: true}, VcenterVMMemorySwapped: MetricConfig{Enabled: true}, VcenterVMMemorySwappedSsd: MetricConfig{Enabled: true}, VcenterVMMemoryUsage: MetricConfig{Enabled: true}, @@ -139,6 +141,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterHostDiskLatencyAvg: MetricConfig{Enabled: false}, VcenterHostDiskLatencyMax: MetricConfig{Enabled: false}, VcenterHostDiskThroughput: MetricConfig{Enabled: false}, + VcenterHostMemoryCapacity: MetricConfig{Enabled: false}, VcenterHostMemoryUsage: MetricConfig{Enabled: false}, VcenterHostMemoryUtilization: MetricConfig{Enabled: false}, VcenterHostNetworkPacketDropRate: MetricConfig{Enabled: false}, @@ -167,6 +170,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterVMDiskUsage: MetricConfig{Enabled: false}, VcenterVMDiskUtilization: MetricConfig{Enabled: false}, VcenterVMMemoryBallooned: MetricConfig{Enabled: false}, + VcenterVMMemoryGranted: MetricConfig{Enabled: false}, VcenterVMMemorySwapped: MetricConfig{Enabled: false}, VcenterVMMemorySwappedSsd: MetricConfig{Enabled: false}, VcenterVMMemoryUsage: MetricConfig{Enabled: false}, diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go index e9acef5599ac..a977af9b516b 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go @@ -1775,6 +1775,57 @@ func newMetricVcenterHostDiskThroughput(cfg MetricConfig) metricVcenterHostDiskT return m } +type metricVcenterHostMemoryCapacity 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 vcenter.host.memory.capacity metric with initial data. +func (m *metricVcenterHostMemoryCapacity) init() { + m.data.SetName("vcenter.host.memory.capacity") + m.data.SetDescription("Total memory capacity of the host system.") + m.data.SetUnit("MiBy") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(false) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricVcenterHostMemoryCapacity) 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 *metricVcenterHostMemoryCapacity) 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 *metricVcenterHostMemoryCapacity) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricVcenterHostMemoryCapacity(cfg MetricConfig) metricVcenterHostMemoryCapacity { + m := metricVcenterHostMemoryCapacity{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricVcenterHostMemoryUsage struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -3208,6 +3259,57 @@ func newMetricVcenterVMMemoryBallooned(cfg MetricConfig) metricVcenterVMMemoryBa return m } +type metricVcenterVMMemoryGranted 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 vcenter.vm.memory.granted metric with initial data. +func (m *metricVcenterVMMemoryGranted) init() { + m.data.SetName("vcenter.vm.memory.granted") + m.data.SetDescription("The amount of memory that is granted to a VM.") + m.data.SetUnit("MiBy") + m.data.SetEmptySum() + m.data.Sum().SetIsMonotonic(false) + m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) +} + +func (m *metricVcenterVMMemoryGranted) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().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 *metricVcenterVMMemoryGranted) 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 *metricVcenterVMMemoryGranted) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricVcenterVMMemoryGranted(cfg MetricConfig) metricVcenterVMMemoryGranted { + m := metricVcenterVMMemoryGranted{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricVcenterVMMemorySwapped struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -3811,6 +3913,7 @@ type MetricsBuilder struct { metricVcenterHostDiskLatencyAvg metricVcenterHostDiskLatencyAvg metricVcenterHostDiskLatencyMax metricVcenterHostDiskLatencyMax metricVcenterHostDiskThroughput metricVcenterHostDiskThroughput + metricVcenterHostMemoryCapacity metricVcenterHostMemoryCapacity metricVcenterHostMemoryUsage metricVcenterHostMemoryUsage metricVcenterHostMemoryUtilization metricVcenterHostMemoryUtilization metricVcenterHostNetworkPacketDropRate metricVcenterHostNetworkPacketDropRate @@ -3839,6 +3942,7 @@ type MetricsBuilder struct { metricVcenterVMDiskUsage metricVcenterVMDiskUsage metricVcenterVMDiskUtilization metricVcenterVMDiskUtilization metricVcenterVMMemoryBallooned metricVcenterVMMemoryBallooned + metricVcenterVMMemoryGranted metricVcenterVMMemoryGranted metricVcenterVMMemorySwapped metricVcenterVMMemorySwapped metricVcenterVMMemorySwappedSsd metricVcenterVMMemorySwappedSsd metricVcenterVMMemoryUsage metricVcenterVMMemoryUsage @@ -3903,6 +4007,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, opt metricVcenterHostDiskLatencyAvg: newMetricVcenterHostDiskLatencyAvg(mbc.Metrics.VcenterHostDiskLatencyAvg), metricVcenterHostDiskLatencyMax: newMetricVcenterHostDiskLatencyMax(mbc.Metrics.VcenterHostDiskLatencyMax), metricVcenterHostDiskThroughput: newMetricVcenterHostDiskThroughput(mbc.Metrics.VcenterHostDiskThroughput), + metricVcenterHostMemoryCapacity: newMetricVcenterHostMemoryCapacity(mbc.Metrics.VcenterHostMemoryCapacity), metricVcenterHostMemoryUsage: newMetricVcenterHostMemoryUsage(mbc.Metrics.VcenterHostMemoryUsage), metricVcenterHostMemoryUtilization: newMetricVcenterHostMemoryUtilization(mbc.Metrics.VcenterHostMemoryUtilization), metricVcenterHostNetworkPacketDropRate: newMetricVcenterHostNetworkPacketDropRate(mbc.Metrics.VcenterHostNetworkPacketDropRate), @@ -3931,6 +4036,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, opt metricVcenterVMDiskUsage: newMetricVcenterVMDiskUsage(mbc.Metrics.VcenterVMDiskUsage), metricVcenterVMDiskUtilization: newMetricVcenterVMDiskUtilization(mbc.Metrics.VcenterVMDiskUtilization), metricVcenterVMMemoryBallooned: newMetricVcenterVMMemoryBallooned(mbc.Metrics.VcenterVMMemoryBallooned), + metricVcenterVMMemoryGranted: newMetricVcenterVMMemoryGranted(mbc.Metrics.VcenterVMMemoryGranted), metricVcenterVMMemorySwapped: newMetricVcenterVMMemorySwapped(mbc.Metrics.VcenterVMMemorySwapped), metricVcenterVMMemorySwappedSsd: newMetricVcenterVMMemorySwappedSsd(mbc.Metrics.VcenterVMMemorySwappedSsd), metricVcenterVMMemoryUsage: newMetricVcenterVMMemoryUsage(mbc.Metrics.VcenterVMMemoryUsage), @@ -4113,6 +4219,7 @@ func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) { mb.metricVcenterHostDiskLatencyAvg.emit(ils.Metrics()) mb.metricVcenterHostDiskLatencyMax.emit(ils.Metrics()) mb.metricVcenterHostDiskThroughput.emit(ils.Metrics()) + mb.metricVcenterHostMemoryCapacity.emit(ils.Metrics()) mb.metricVcenterHostMemoryUsage.emit(ils.Metrics()) mb.metricVcenterHostMemoryUtilization.emit(ils.Metrics()) mb.metricVcenterHostNetworkPacketDropRate.emit(ils.Metrics()) @@ -4141,6 +4248,7 @@ func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) { mb.metricVcenterVMDiskUsage.emit(ils.Metrics()) mb.metricVcenterVMDiskUtilization.emit(ils.Metrics()) mb.metricVcenterVMMemoryBallooned.emit(ils.Metrics()) + mb.metricVcenterVMMemoryGranted.emit(ils.Metrics()) mb.metricVcenterVMMemorySwapped.emit(ils.Metrics()) mb.metricVcenterVMMemorySwappedSsd.emit(ils.Metrics()) mb.metricVcenterVMMemoryUsage.emit(ils.Metrics()) @@ -4318,6 +4426,11 @@ func (mb *MetricsBuilder) RecordVcenterHostDiskThroughputDataPoint(ts pcommon.Ti mb.metricVcenterHostDiskThroughput.recordDataPoint(mb.startTime, ts, val, diskDirectionAttributeValue.String(), objectNameAttributeValue) } +// RecordVcenterHostMemoryCapacityDataPoint adds a data point to vcenter.host.memory.capacity metric. +func (mb *MetricsBuilder) RecordVcenterHostMemoryCapacityDataPoint(ts pcommon.Timestamp, val float64) { + mb.metricVcenterHostMemoryCapacity.recordDataPoint(mb.startTime, ts, val) +} + // RecordVcenterHostMemoryUsageDataPoint adds a data point to vcenter.host.memory.usage metric. func (mb *MetricsBuilder) RecordVcenterHostMemoryUsageDataPoint(ts pcommon.Timestamp, val int64) { mb.metricVcenterHostMemoryUsage.recordDataPoint(mb.startTime, ts, val) @@ -4458,6 +4571,11 @@ func (mb *MetricsBuilder) RecordVcenterVMMemoryBalloonedDataPoint(ts pcommon.Tim mb.metricVcenterVMMemoryBallooned.recordDataPoint(mb.startTime, ts, val) } +// RecordVcenterVMMemoryGrantedDataPoint adds a data point to vcenter.vm.memory.granted metric. +func (mb *MetricsBuilder) RecordVcenterVMMemoryGrantedDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricVcenterVMMemoryGranted.recordDataPoint(mb.startTime, ts, val) +} + // RecordVcenterVMMemorySwappedDataPoint adds a data point to vcenter.vm.memory.swapped metric. func (mb *MetricsBuilder) RecordVcenterVMMemorySwappedDataPoint(ts pcommon.Timestamp, val int64) { mb.metricVcenterVMMemorySwapped.recordDataPoint(mb.startTime, ts, val) diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go index 68730fb5a7b3..f286196dda59 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go @@ -176,6 +176,9 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordVcenterHostDiskThroughputDataPoint(ts, 1, AttributeDiskDirectionRead, "object_name-val") + allMetricsCount++ + mb.RecordVcenterHostMemoryCapacityDataPoint(ts, 1) + defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostMemoryUsageDataPoint(ts, 1) @@ -288,6 +291,9 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordVcenterVMMemoryBalloonedDataPoint(ts, 1) + allMetricsCount++ + mb.RecordVcenterVMMemoryGrantedDataPoint(ts, 1) + defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemorySwappedDataPoint(ts, 1) @@ -783,6 +789,20 @@ func TestMetricsBuilder(t *testing.T) { attrVal, ok = dp.Attributes().Get("object") assert.True(t, ok) assert.EqualValues(t, "object_name-val", attrVal.Str()) + case "vcenter.host.memory.capacity": + assert.False(t, validatedMetrics["vcenter.host.memory.capacity"], "Found a duplicate in the metrics slice: vcenter.host.memory.capacity") + validatedMetrics["vcenter.host.memory.capacity"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Total memory capacity of the host system.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, 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.InDelta(t, float64(1), dp.DoubleValue(), 0.01) case "vcenter.host.memory.usage": assert.False(t, validatedMetrics["vcenter.host.memory.usage"], "Found a duplicate in the metrics slice: vcenter.host.memory.usage") validatedMetrics["vcenter.host.memory.usage"] = true @@ -1208,6 +1228,20 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) + case "vcenter.vm.memory.granted": + assert.False(t, validatedMetrics["vcenter.vm.memory.granted"], "Found a duplicate in the metrics slice: vcenter.vm.memory.granted") + validatedMetrics["vcenter.vm.memory.granted"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to a VM.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, 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.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) case "vcenter.vm.memory.swapped": assert.False(t, validatedMetrics["vcenter.vm.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped") validatedMetrics["vcenter.vm.memory.swapped"] = true diff --git a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml index f43f41c63169..ce2aae9f092d 100644 --- a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml @@ -55,6 +55,8 @@ all_set: enabled: true vcenter.host.disk.throughput: enabled: true + vcenter.host.memory.capacity: + enabled: true vcenter.host.memory.usage: enabled: true vcenter.host.memory.utilization: @@ -111,6 +113,8 @@ all_set: enabled: true vcenter.vm.memory.ballooned: enabled: true + vcenter.vm.memory.granted: + enabled: true vcenter.vm.memory.swapped: enabled: true vcenter.vm.memory.swapped_ssd: @@ -214,6 +218,8 @@ none_set: enabled: false vcenter.host.disk.throughput: enabled: false + vcenter.host.memory.capacity: + enabled: false vcenter.host.memory.usage: enabled: false vcenter.host.memory.utilization: @@ -270,6 +276,8 @@ none_set: enabled: false vcenter.vm.memory.ballooned: enabled: false + vcenter.vm.memory.granted: + enabled: false vcenter.vm.memory.swapped: enabled: false vcenter.vm.memory.swapped_ssd: diff --git a/receiver/vcenterreceiver/metadata.yaml b/receiver/vcenterreceiver/metadata.yaml index cc63bba99108..dbb677050c54 100644 --- a/receiver/vcenterreceiver/metadata.yaml +++ b/receiver/vcenterreceiver/metadata.yaml @@ -413,6 +413,15 @@ metrics: value_type: int aggregation_temporality: cumulative attributes: [] + vcenter.host.memory.capacity: + enabled: false + description: Total memory capacity of the host system. + unit: MiBy + sum: + monotonic: false + value_type: double + aggregation_temporality: cumulative + attributes: [] vcenter.host.network.throughput: enabled: true description: The amount of data that was transmitted or received over the network by the host. @@ -568,6 +577,15 @@ metrics: value_type: int aggregation_temporality: cumulative attributes: [] + vcenter.vm.memory.granted: + enabled: false + description: The amount of memory that is granted to a VM. + unit: MiBy + sum: + monotonic: false + value_type: int + aggregation_temporality: cumulative + attributes: [] vcenter.vm.memory.usage: enabled: true description: The amount of memory that is used by the virtual machine. @@ -720,4 +738,4 @@ metrics: unit: "us" gauge: value_type: int - attributes: [vsan_latency_type] + attributes: [vsan_latency_type] \ No newline at end of file diff --git a/receiver/vcenterreceiver/metrics.go b/receiver/vcenterreceiver/metrics.go index ab3bd4927940..199da2fa8317 100644 --- a/receiver/vcenterreceiver/metrics.go +++ b/receiver/vcenterreceiver/metrics.go @@ -217,6 +217,7 @@ func (v *vcenterMetricScraper) recordHostSystemStats( cpuCapacity := float64(int32(h.NumCpuCores) * h.CpuMhz) v.mb.RecordVcenterHostCPUCapacityDataPoint(ts, int64(cpuCapacity)) + v.mb.RecordVcenterHostMemoryCapacityDataPoint(ts, float64(h.MemorySize>>20)) cpuUtilization := 100 * float64(z.OverallCpuUsage) / cpuCapacity v.mb.RecordVcenterHostCPUUtilizationDataPoint(ts, cpuUtilization) } @@ -276,6 +277,7 @@ func (v *vcenterMetricScraper) recordVMStats( balloonedMem := vm.Summary.QuickStats.BalloonedMemory swappedMem := vm.Summary.QuickStats.SwappedMemory swappedSSDMem := vm.Summary.QuickStats.SsdSwappedMemory + grantedMem := vm.Summary.QuickStats.GrantedMemory if totalMemory := vm.Summary.Config.MemorySizeMB; totalMemory > 0 && memUsage > 0 { memoryUtilization := float64(memUsage) / float64(totalMemory) * 100 @@ -286,6 +288,7 @@ func (v *vcenterMetricScraper) recordVMStats( v.mb.RecordVcenterVMMemoryBalloonedDataPoint(ts, int64(balloonedMem)) v.mb.RecordVcenterVMMemorySwappedDataPoint(ts, int64(swappedMem)) v.mb.RecordVcenterVMMemorySwappedSsdDataPoint(ts, swappedSSDMem) + v.mb.RecordVcenterVMMemoryGrantedDataPoint(ts, int64(grantedMem)) cpuUsage := vm.Summary.QuickStats.OverallCpuUsage if cpuUsage == 0 { diff --git a/receiver/vcenterreceiver/scraper_test.go b/receiver/vcenterreceiver/scraper_test.go index ce703c1e04b5..c30d3e29641d 100644 --- a/receiver/vcenterreceiver/scraper_test.go +++ b/receiver/vcenterreceiver/scraper_test.go @@ -40,6 +40,8 @@ func TestScrapeConfigsEnabled(t *testing.T) { defer mockServer.Close() optConfigs := metadata.DefaultMetricsBuilderConfig() + optConfigs.Metrics.VcenterHostMemoryCapacity.Enabled = true + optConfigs.Metrics.VcenterVMMemoryGranted.Enabled = true setResourcePoolMemoryUsageAttrFeatureGate(t, true) cfg := &Config{ diff --git a/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml b/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml index 8edb20c45500..a850c3d2669b 100644 --- a/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml +++ b/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml @@ -597,6 +597,15 @@ resourceMetrics: startTimeUnixNano: "2000000" timeUnixNano: "1000000" unit: '{KiBy/s}' + - description: Total memory capacity of the host system. + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 784648.000000 + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + name: vcenter.host.memory.capacity + unit: 'MiBy' - description: The amount of memory the host system is using. name: vcenter.host.memory.usage sum: @@ -1332,6 +1341,15 @@ resourceMetrics: startTimeUnixNano: "2000000" timeUnixNano: "1000000" unit: '{KiBy/s}' + - description: Total memory capacity of the host system. + sum: + aggregationTemporality: 2 + dataPoints: + - asDouble: 784648.000000 + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + name: vcenter.host.memory.capacity + unit: 'MiBy' - description: The amount of memory the host system is using. name: vcenter.host.memory.usage sum: @@ -2291,6 +2309,15 @@ resourceMetrics: startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: MiBy + - description: The amount of memory that is granted to a VM. + name: vcenter.vm.memory.granted + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "0" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: MiBy - description: The portion of memory that is granted to this VM from the host's swap space. name: vcenter.vm.memory.swapped sum: @@ -2928,6 +2955,15 @@ resourceMetrics: startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: MiBy + - description: The amount of memory that is granted to a VM. + name: vcenter.vm.memory.granted + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "0" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: MiBy - description: The portion of memory that is granted to this VM from the host's swap space. name: vcenter.vm.memory.swapped sum: @@ -3664,6 +3700,15 @@ resourceMetrics: startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: MiBy + - description: The amount of memory that is granted to a VM. + name: vcenter.vm.memory.granted + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "0" + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: MiBy - description: The portion of memory that is granted to this VM from the host's swap space. name: vcenter.vm.memory.swapped sum: