From 0debbc69591c44505648072d7c45133000d5f2b7 Mon Sep 17 00:00:00 2001 From: Stefan Kurek Date: Tue, 7 May 2024 14:50:04 -0400 Subject: [PATCH] vcenterreceiver adds VM packets drop rate metric --- ...eat_vcenter-vm-add-packet-drop-metric.yaml | 27 ++ ...ix_vcenter-vm-add-new-packet-metrics.yaml} | 0 receiver/vcenterreceiver/documentation.md | 17 + .../internal/metadata/generated_config.go | 4 + .../metadata/generated_config_test.go | 2 + .../internal/metadata/generated_metrics.go | 63 +++ .../metadata/generated_metrics_test.go | 25 ++ .../internal/metadata/testdata/config.yaml | 4 + .../responses/vm-performance-counters.xml | 252 ++++++++++++ receiver/vcenterreceiver/metadata.yaml | 10 + receiver/vcenterreceiver/metrics.go | 8 + receiver/vcenterreceiver/scraper_test.go | 1 + .../metrics/expected-all-enabled.yaml | 375 ++++++++++++++++++ 13 files changed, 788 insertions(+) create mode 100644 .chloggen/feat_vcenter-vm-add-packet-drop-metric.yaml rename .chloggen/{fix_vcenter-vm-add-disk-metric copy.yaml => fix_vcenter-vm-add-new-packet-metrics.yaml} (100%) diff --git a/.chloggen/feat_vcenter-vm-add-packet-drop-metric.yaml b/.chloggen/feat_vcenter-vm-add-packet-drop-metric.yaml new file mode 100644 index 000000000000..bcc960441c35 --- /dev/null +++ b/.chloggen/feat_vcenter-vm-add-packet-drop-metric.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# 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 inititially disabled packet drop rate 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: [32929] + +# (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/.chloggen/fix_vcenter-vm-add-disk-metric copy.yaml b/.chloggen/fix_vcenter-vm-add-new-packet-metrics.yaml similarity index 100% rename from .chloggen/fix_vcenter-vm-add-disk-metric copy.yaml rename to .chloggen/fix_vcenter-vm-add-new-packet-metrics.yaml diff --git a/receiver/vcenterreceiver/documentation.md b/receiver/vcenterreceiver/documentation.md index 95ccdee031cb..daf1dd02610a 100644 --- a/receiver/vcenterreceiver/documentation.md +++ b/receiver/vcenterreceiver/documentation.md @@ -508,6 +508,23 @@ The memory utilization of the VM. | ---- | ----------- | ---------- | | % | Gauge | Double | +### vcenter.vm.network.packet.drop.rate + +The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine. + +As measured over the most recent 20s interval. + +| Unit | Metric Type | Value Type | +| ---- | ----------- | ---------- | +| {packets/sec} | Gauge | Double | + +#### Attributes + +| Name | Description | Values | +| ---- | ----------- | ------ | +| direction | The direction of network throughput. | Str: ``transmitted``, ``received`` | +| object | The object on the virtual machine or host that is being reported on. | Any Str | + ### vcenter.vm.network.packet.rate The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine. diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config.go b/receiver/vcenterreceiver/internal/metadata/generated_config.go index 75de09a40b35..954b1ffa1748 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config.go @@ -68,6 +68,7 @@ type MetricsConfig struct { VcenterVMMemoryUsage MetricConfig `mapstructure:"vcenter.vm.memory.usage"` VcenterVMMemoryUtilization MetricConfig `mapstructure:"vcenter.vm.memory.utilization"` VcenterVMNetworkPacketCount MetricConfig `mapstructure:"vcenter.vm.network.packet.count"` + VcenterVMNetworkPacketDropRate MetricConfig `mapstructure:"vcenter.vm.network.packet.drop.rate"` VcenterVMNetworkPacketRate MetricConfig `mapstructure:"vcenter.vm.network.packet.rate"` VcenterVMNetworkThroughput MetricConfig `mapstructure:"vcenter.vm.network.throughput"` VcenterVMNetworkUsage MetricConfig `mapstructure:"vcenter.vm.network.usage"` @@ -195,6 +196,9 @@ func DefaultMetricsConfig() MetricsConfig { VcenterVMNetworkPacketCount: MetricConfig{ Enabled: true, }, + VcenterVMNetworkPacketDropRate: MetricConfig{ + Enabled: false, + }, VcenterVMNetworkPacketRate: MetricConfig{ Enabled: false, }, diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go index 217d33534c6f..a3f28c5d3dd7 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go @@ -66,6 +66,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterVMMemoryUsage: MetricConfig{Enabled: true}, VcenterVMMemoryUtilization: MetricConfig{Enabled: true}, VcenterVMNetworkPacketCount: MetricConfig{Enabled: true}, + VcenterVMNetworkPacketDropRate: MetricConfig{Enabled: true}, VcenterVMNetworkPacketRate: MetricConfig{Enabled: true}, VcenterVMNetworkThroughput: MetricConfig{Enabled: true}, VcenterVMNetworkUsage: MetricConfig{Enabled: true}, @@ -130,6 +131,7 @@ func TestMetricsBuilderConfig(t *testing.T) { VcenterVMMemoryUsage: MetricConfig{Enabled: false}, VcenterVMMemoryUtilization: MetricConfig{Enabled: false}, VcenterVMNetworkPacketCount: MetricConfig{Enabled: false}, + VcenterVMNetworkPacketDropRate: MetricConfig{Enabled: false}, VcenterVMNetworkPacketRate: MetricConfig{Enabled: false}, VcenterVMNetworkThroughput: MetricConfig{Enabled: false}, VcenterVMNetworkUsage: MetricConfig{Enabled: false}, diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go index 0198c24e9598..efe7064ca54c 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go @@ -2205,6 +2205,58 @@ func newMetricVcenterVMNetworkPacketCount(cfg MetricConfig) metricVcenterVMNetwo return m } +type metricVcenterVMNetworkPacketDropRate 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.network.packet.drop.rate metric with initial data. +func (m *metricVcenterVMNetworkPacketDropRate) init() { + m.data.SetName("vcenter.vm.network.packet.drop.rate") + m.data.SetDescription("The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine.") + m.data.SetUnit("{packets/sec}") + m.data.SetEmptyGauge() + m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) +} + +func (m *metricVcenterVMNetworkPacketDropRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Gauge().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetDoubleValue(val) + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + dp.Attributes().PutStr("object", objectNameAttributeValue) +} + +// updateCapacity saves max length of data point slices that will be used for the slice capacity. +func (m *metricVcenterVMNetworkPacketDropRate) 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 *metricVcenterVMNetworkPacketDropRate) emit(metrics pmetric.MetricSlice) { + if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + m.updateCapacity() + m.data.MoveTo(metrics.AppendEmpty()) + m.init() + } +} + +func newMetricVcenterVMNetworkPacketDropRate(cfg MetricConfig) metricVcenterVMNetworkPacketDropRate { + m := metricVcenterVMNetworkPacketDropRate{config: cfg} + if cfg.Enabled { + m.data = pmetric.NewMetric() + m.init() + } + return m +} + type metricVcenterVMNetworkPacketRate struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. @@ -2414,6 +2466,7 @@ type MetricsBuilder struct { metricVcenterVMMemoryUsage metricVcenterVMMemoryUsage metricVcenterVMMemoryUtilization metricVcenterVMMemoryUtilization metricVcenterVMNetworkPacketCount metricVcenterVMNetworkPacketCount + metricVcenterVMNetworkPacketDropRate metricVcenterVMNetworkPacketDropRate metricVcenterVMNetworkPacketRate metricVcenterVMNetworkPacketRate metricVcenterVMNetworkThroughput metricVcenterVMNetworkThroughput metricVcenterVMNetworkUsage metricVcenterVMNetworkUsage @@ -2451,6 +2504,9 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting if mbc.Metrics.VcenterVMNetworkPacketCount.enabledSetByUser { settings.Logger.Warn("[WARNING] `vcenter.vm.network.packet.count` should not be configured: this metric is replaced by [vcenter.vm.network.packet.rate] & will be removed starting in release v0.102.0") } + if !mbc.Metrics.VcenterVMNetworkPacketDropRate.enabledSetByUser { + settings.Logger.Warn("[WARNING] Please set `enabled` field explicitly for `vcenter.vm.network.packet.drop.rate`: this metric will be enabled by default starting in release v0.102.0") + } if !mbc.Metrics.VcenterVMNetworkPacketRate.enabledSetByUser { settings.Logger.Warn("[WARNING] Please set `enabled` field explicitly for `vcenter.vm.network.packet.rate`: this metric will be enabled by default starting in release v0.102.0") } @@ -2514,6 +2570,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting metricVcenterVMMemoryUsage: newMetricVcenterVMMemoryUsage(mbc.Metrics.VcenterVMMemoryUsage), metricVcenterVMMemoryUtilization: newMetricVcenterVMMemoryUtilization(mbc.Metrics.VcenterVMMemoryUtilization), metricVcenterVMNetworkPacketCount: newMetricVcenterVMNetworkPacketCount(mbc.Metrics.VcenterVMNetworkPacketCount), + metricVcenterVMNetworkPacketDropRate: newMetricVcenterVMNetworkPacketDropRate(mbc.Metrics.VcenterVMNetworkPacketDropRate), metricVcenterVMNetworkPacketRate: newMetricVcenterVMNetworkPacketRate(mbc.Metrics.VcenterVMNetworkPacketRate), metricVcenterVMNetworkThroughput: newMetricVcenterVMNetworkThroughput(mbc.Metrics.VcenterVMNetworkThroughput), metricVcenterVMNetworkUsage: newMetricVcenterVMNetworkUsage(mbc.Metrics.VcenterVMNetworkUsage), @@ -2693,6 +2750,7 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricVcenterVMMemoryUsage.emit(ils.Metrics()) mb.metricVcenterVMMemoryUtilization.emit(ils.Metrics()) mb.metricVcenterVMNetworkPacketCount.emit(ils.Metrics()) + mb.metricVcenterVMNetworkPacketDropRate.emit(ils.Metrics()) mb.metricVcenterVMNetworkPacketRate.emit(ils.Metrics()) mb.metricVcenterVMNetworkThroughput.emit(ils.Metrics()) mb.metricVcenterVMNetworkUsage.emit(ils.Metrics()) @@ -2927,6 +2985,11 @@ func (mb *MetricsBuilder) RecordVcenterVMNetworkPacketCountDataPoint(ts pcommon. mb.metricVcenterVMNetworkPacketCount.recordDataPoint(mb.startTime, ts, val, throughputDirectionAttributeValue.String(), objectNameAttributeValue) } +// RecordVcenterVMNetworkPacketDropRateDataPoint adds a data point to vcenter.vm.network.packet.drop.rate metric. +func (mb *MetricsBuilder) RecordVcenterVMNetworkPacketDropRateDataPoint(ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue AttributeThroughputDirection, objectNameAttributeValue string) { + mb.metricVcenterVMNetworkPacketDropRate.recordDataPoint(mb.startTime, ts, val, throughputDirectionAttributeValue.String(), objectNameAttributeValue) +} + // RecordVcenterVMNetworkPacketRateDataPoint adds a data point to vcenter.vm.network.packet.rate metric. func (mb *MetricsBuilder) RecordVcenterVMNetworkPacketRateDataPoint(ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue AttributeThroughputDirection, objectNameAttributeValue string) { mb.metricVcenterVMNetworkPacketRate.recordDataPoint(mb.startTime, ts, val, throughputDirectionAttributeValue.String(), objectNameAttributeValue) diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go index 17c03a8be2c5..0285523faed5 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go @@ -90,6 +90,10 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, "[WARNING] `vcenter.vm.network.packet.count` should not be configured: this metric is replaced by [vcenter.vm.network.packet.rate] & will be removed starting in release v0.102.0", observedLogs.All()[expectedWarnings].Message) expectedWarnings++ } + if test.metricsSet == testDataSetDefault { + assert.Equal(t, "[WARNING] Please set `enabled` field explicitly for `vcenter.vm.network.packet.drop.rate`: this metric will be enabled by default starting in release v0.102.0", observedLogs.All()[expectedWarnings].Message) + expectedWarnings++ + } if test.metricsSet == testDataSetDefault { assert.Equal(t, "[WARNING] Please set `enabled` field explicitly for `vcenter.vm.network.packet.rate`: this metric will be enabled by default starting in release v0.102.0", observedLogs.All()[expectedWarnings].Message) expectedWarnings++ @@ -276,6 +280,9 @@ func TestMetricsBuilder(t *testing.T) { allMetricsCount++ mb.RecordVcenterVMNetworkPacketCountDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + allMetricsCount++ + mb.RecordVcenterVMNetworkPacketDropRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + allMetricsCount++ mb.RecordVcenterVMNetworkPacketRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") @@ -940,6 +947,24 @@ 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.vm.network.packet.drop.rate": + assert.False(t, validatedMetrics["vcenter.vm.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.drop.rate") + validatedMetrics["vcenter.vm.network.packet.drop.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/sec}", 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()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.EqualValues(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.EqualValues(t, "object_name-val", attrVal.Str()) case "vcenter.vm.network.packet.rate": assert.False(t, validatedMetrics["vcenter.vm.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.rate") validatedMetrics["vcenter.vm.network.packet.rate"] = true diff --git a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml index 2f1281bc668f..0e9970eadf8e 100644 --- a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml @@ -81,6 +81,8 @@ all_set: enabled: true vcenter.vm.network.packet.count: enabled: true + vcenter.vm.network.packet.drop.rate: + enabled: true vcenter.vm.network.packet.rate: enabled: true vcenter.vm.network.throughput: @@ -194,6 +196,8 @@ none_set: enabled: false vcenter.vm.network.packet.count: enabled: false + vcenter.vm.network.packet.drop.rate: + enabled: false vcenter.vm.network.packet.rate: enabled: false vcenter.vm.network.throughput: diff --git a/receiver/vcenterreceiver/internal/mockserver/responses/vm-performance-counters.xml b/receiver/vcenterreceiver/internal/mockserver/responses/vm-performance-counters.xml index 005407144536..59f89bf27dab 100644 --- a/receiver/vcenterreceiver/internal/mockserver/responses/vm-performance-counters.xml +++ b/receiver/vcenterreceiver/internal/mockserver/responses/vm-performance-counters.xml @@ -64,6 +64,20 @@ 0 + + + 530 + + + 40 + + + + 529 + + + 20 + 143 @@ -85,6 +99,13 @@ 0 + + + 530 + vmnic3 + + 40 + 531 @@ -99,6 +120,13 @@ 0 + + + 530 + vmnic2 + + 40 + 143 @@ -148,6 +176,20 @@ 0 + + + 530 + vmnic1 + + 40 + + + + 529 + vmnic1 + + 20 + 143 @@ -169,6 +211,20 @@ 0 + + + 530 + vmnic0 + + 40 + + + + 529 + vmnic0 + + 20 + 143 @@ -183,6 +239,13 @@ 0 + + + 529 + vmnic3 + + 20 + 146 @@ -190,6 +253,13 @@ 0 + + + 529 + vmnic2 + + 20 + 532 @@ -246,6 +316,13 @@ 0 + + + 529 + 4000 + + 20 + 147 @@ -253,6 +330,13 @@ 0 + + + 530 + 4000 + + 40 + 532 @@ -330,6 +414,20 @@ 0 + + + 530 + + + 40 + + + + 529 + + + 20 + 143 @@ -351,6 +449,13 @@ 0 + + + 530 + vmnic3 + + 40 + 531 @@ -365,6 +470,13 @@ 0 + + + 530 + vmnic2 + + 40 + 143 @@ -414,6 +526,20 @@ 0 + + + 530 + vmnic1 + + 40 + + + + 529 + vmnic1 + + 20 + 143 @@ -435,6 +561,20 @@ 0 + + + 530 + vmnic0 + + 40 + + + + 529 + vmnic0 + + 20 + 143 @@ -449,6 +589,13 @@ 0 + + + 529 + vmnic3 + + 20 + 146 @@ -456,6 +603,13 @@ 0 + + + 529 + vmnic2 + + 20 + 532 @@ -519,6 +673,20 @@ 0 + + + 530 + 4000 + + 40 + + + + 529 + 4000 + + 20 + 532 @@ -596,6 +764,20 @@ 0 + + + 530 + + + 40 + + + + 529 + + + 20 + 143 @@ -617,6 +799,13 @@ 0 + + + 530 + vmnic3 + + 40 + 531 @@ -631,6 +820,13 @@ 0 + + + 530 + vmnic2 + + 40 + 143 @@ -680,6 +876,20 @@ 0 + + + 530 + vmnic1 + + 40 + + + + 529 + vmnic1 + + 20 + 143 @@ -701,6 +911,20 @@ 0 + + + 530 + vmnic0 + + 40 + + + + 529 + vmnic0 + + 20 + 143 @@ -715,6 +939,13 @@ 0 + + + 529 + vmnic3 + + 20 + 146 @@ -722,6 +953,13 @@ 0 + + + 529 + vmnic2 + + 20 + 532 @@ -785,6 +1023,20 @@ 0 + + + 529 + 4000 + + 20 + + + + 530 + 4000 + + 40 + 532 diff --git a/receiver/vcenterreceiver/metadata.yaml b/receiver/vcenterreceiver/metadata.yaml index de6e8624c04f..fab23a923e28 100644 --- a/receiver/vcenterreceiver/metadata.yaml +++ b/receiver/vcenterreceiver/metadata.yaml @@ -470,6 +470,16 @@ metrics: extended_documentation: As measured over the most recent 20s interval. warnings: if_enabled_not_set: "this metric will be enabled by default starting in release v0.102.0" + vcenter.vm.network.packet.drop.rate: + enabled: false + description: The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine. + unit: "{packets/sec}" + gauge: + value_type: double + attributes: [throughput_direction, object_name] + extended_documentation: As measured over the most recent 20s interval. + warnings: + if_enabled_not_set: "this metric will be enabled by default starting in release v0.102.0" vcenter.vm.network.usage: enabled: true description: The network utilization combined transmit and receive rates during an interval. diff --git a/receiver/vcenterreceiver/metrics.go b/receiver/vcenterreceiver/metrics.go index e1dd574d3a31..6114206f0b2f 100644 --- a/receiver/vcenterreceiver/metrics.go +++ b/receiver/vcenterreceiver/metrics.go @@ -166,6 +166,8 @@ var vmPerfMetricList = []string{ // network metrics "net.packetsTx.summation", "net.packetsRx.summation", + "net.droppedTx.summation", + "net.droppedRx.summation", "net.bytesRx.average", "net.bytesTx.average", "net.usage.average", @@ -216,6 +218,12 @@ func (v *vcenterMetricScraper) recordVMPerformanceMetrics(entityMetric *performa v.mb.RecordVcenterVMDiskThroughputDataPoint(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionRead, val.Instance) case "virtualDisk.write.average": v.mb.RecordVcenterVMDiskThroughputDataPoint(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionWrite, val.Instance) + case "net.droppedTx.summation": + txRate := float64(nestedValue) / 20 + v.mb.RecordVcenterVMNetworkPacketDropRateDataPoint(pcommon.NewTimestampFromTime(si.Timestamp), txRate, metadata.AttributeThroughputDirectionTransmitted, val.Instance) + case "net.droppedRx.summation": + rxRate := float64(nestedValue) / 20 + v.mb.RecordVcenterVMNetworkPacketDropRateDataPoint(pcommon.NewTimestampFromTime(si.Timestamp), rxRate, metadata.AttributeThroughputDirectionReceived, val.Instance) } } } diff --git a/receiver/vcenterreceiver/scraper_test.go b/receiver/vcenterreceiver/scraper_test.go index fd84ca3cc96e..fefeb86ce2cc 100644 --- a/receiver/vcenterreceiver/scraper_test.go +++ b/receiver/vcenterreceiver/scraper_test.go @@ -49,6 +49,7 @@ func TestScrapeConfigsEnabled(t *testing.T) { optConfigs.Metrics.VcenterHostNetworkPacketErrorRate.Enabled = true optConfigs.Metrics.VcenterHostNetworkPacketRate.Enabled = true optConfigs.Metrics.VcenterVMNetworkPacketRate.Enabled = true + optConfigs.Metrics.VcenterVMNetworkPacketDropRate.Enabled = true cfg := &Config{ MetricsBuilderConfig: optConfigs, diff --git a/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml b/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml index a9e4f8af7c96..5e201d4220a3 100644 --- a/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml +++ b/receiver/vcenterreceiver/testdata/metrics/expected-all-enabled.yaml @@ -7544,6 +7544,131 @@ resourceMetrics: startTimeUnixNano: "2000000" timeUnixNano: "1000000" unit: '{packets/sec}' + - description: The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine. + name: vcenter.vm.network.packet.drop.rate + gauge: + dataPoints: + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + unit: '{packets/sec}' - description: The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine. name: vcenter.vm.network.packet.rate gauge: @@ -8216,6 +8341,131 @@ resourceMetrics: startTimeUnixNano: "2000000" timeUnixNano: "1000000" unit: '{packets/sec}' + - description: The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine. + name: vcenter.vm.network.packet.drop.rate + gauge: + dataPoints: + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + unit: '{packets/sec}' - description: The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine. name: vcenter.vm.network.packet.rate gauge: @@ -8843,6 +9093,131 @@ resourceMetrics: startTimeUnixNano: "2000000" timeUnixNano: "1000000" unit: '{packets/sec}' + - description: The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine. + name: vcenter.vm.network.packet.drop.rate + gauge: + dataPoints: + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "1" + attributes: + - key: direction + value: + stringValue: received + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: "4000" + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic0 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic1 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic2 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + - asDouble: "2" + attributes: + - key: direction + value: + stringValue: transmitted + - key: object + value: + stringValue: vmnic3 + startTimeUnixNano: "2000000" + timeUnixNano: "1000000" + unit: '{packets/sec}' - description: The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine. name: vcenter.vm.network.packet.rate gauge: