From 440d01d05d85f0725dbc720f748681e71f9458aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Tudur=C3=AD?= Date: Thu, 16 Nov 2023 17:28:59 +0100 Subject: [PATCH] flow: Add otelcol.receiver.vcenter component (#5715) Co-authored-by: Paulin Todev --- CHANGELOG.md | 1 + component/all/all.go | 1 + component/otelcol/config_scrape.go | 58 +++ component/otelcol/receiver/vcenter/vcenter.go | 331 ++++++++++++++++++ .../otelcol/receiver/vcenter/vcenter_test.go | 42 +++ .../components/otelcol.receiver.vcenter.md | 143 ++++++++ .../components/prometheus.exporter.vsphere.md | 7 +- go.mod | 3 +- go.sum | 11 +- 9 files changed, 590 insertions(+), 7 deletions(-) create mode 100644 component/otelcol/config_scrape.go create mode 100644 component/otelcol/receiver/vcenter/vcenter.go create mode 100644 component/otelcol/receiver/vcenter/vcenter_test.go create mode 100644 docs/sources/flow/reference/components/otelcol.receiver.vcenter.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e09b7cb96c7..5dd878676da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Main (unreleased) - `otelcol.processor.filter` - filters OTLP telemetry data using OpenTelemetry Transformation Language (OTTL). (@hainenber) + - `otelcol.receiver.vcenter` - receives metrics telemetry data from vCenter. (@marctc) - Agent Management: Introduce support for remotely managed external labels for logs. (@jcreixell) diff --git a/component/all/all.go b/component/all/all.go index 79da39323077..3822deee7c9c 100644 --- a/component/all/all.go +++ b/component/all/all.go @@ -89,6 +89,7 @@ import ( _ "github.com/grafana/agent/component/otelcol/receiver/opencensus" // Import otelcol.receiver.opencensus _ "github.com/grafana/agent/component/otelcol/receiver/otlp" // Import otelcol.receiver.otlp _ "github.com/grafana/agent/component/otelcol/receiver/prometheus" // Import otelcol.receiver.prometheus + _ "github.com/grafana/agent/component/otelcol/receiver/vcenter" // Import otelcol.receiver.vcenter _ "github.com/grafana/agent/component/otelcol/receiver/zipkin" // Import otelcol.receiver.zipkin _ "github.com/grafana/agent/component/prometheus/exporter/agent" // Import prometheus.exporter.agent _ "github.com/grafana/agent/component/prometheus/exporter/apache" // Import prometheus.exporter.apache diff --git a/component/otelcol/config_scrape.go b/component/otelcol/config_scrape.go new file mode 100644 index 000000000000..60f30ae946ac --- /dev/null +++ b/component/otelcol/config_scrape.go @@ -0,0 +1,58 @@ +package otelcol + +import ( + "errors" + "fmt" + "time" + + scraperhelper "go.opentelemetry.io/collector/receiver/scraperhelper" +) + +var ( + errNonPositiveInterval = errors.New("requires positive value") + errGreaterThanZero = errors.New("requires a value greater than zero") +) + +// ScraperControllerArguments defines common settings for a scraper controller +// configuration. +type ScraperControllerArguments struct { + CollectionInterval time.Duration `river:"collection_interval,attr,optional"` + InitialDelay time.Duration `river:"initial_delay,attr,optional"` + Timeout time.Duration `river:"timeout,attr,optional"` +} + +// DefaultScraperControllerArguments holds default settings for ScraperControllerArguments. +var DefaultScraperControllerArguments = ScraperControllerArguments{ + CollectionInterval: time.Minute, + InitialDelay: time.Second, + Timeout: 0 * time.Second, +} + +// SetToDefault implements river.Defaulter. +func (args *ScraperControllerArguments) SetToDefault() { + *args = DefaultScraperControllerArguments +} + +// Convert converts args into the upstream type. +func (args *ScraperControllerArguments) Convert() *scraperhelper.ScraperControllerSettings { + if args == nil { + return nil + } + + return &scraperhelper.ScraperControllerSettings{ + CollectionInterval: args.CollectionInterval, + InitialDelay: args.InitialDelay, + Timeout: args.Timeout, + } +} + +// Validate returns an error if args is invalid. +func (args *ScraperControllerArguments) Validate() error { + if args.CollectionInterval <= 0 { + return fmt.Errorf(`"collection_interval": %w`, errNonPositiveInterval) + } + if args.Timeout < 0 { + return fmt.Errorf(`"timeout": %w`, errGreaterThanZero) + } + return nil +} diff --git a/component/otelcol/receiver/vcenter/vcenter.go b/component/otelcol/receiver/vcenter/vcenter.go new file mode 100644 index 000000000000..88efd9402940 --- /dev/null +++ b/component/otelcol/receiver/vcenter/vcenter.go @@ -0,0 +1,331 @@ +// Package vcenter provides an otelcol.receiver.vcenter component. +package vcenter + +import ( + "fmt" + "net/url" + + "github.com/grafana/agent/component" + "github.com/grafana/agent/component/otelcol" + "github.com/grafana/agent/component/otelcol/receiver" + otel_service "github.com/grafana/agent/service/otel" + "github.com/grafana/river/rivertypes" + "github.com/mitchellh/mapstructure" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" + otelcomponent "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/config/configopaque" + otelextension "go.opentelemetry.io/collector/extension" +) + +func init() { + component.Register(component.Registration{ + Name: "otelcol.receiver.vcenter", + Args: Arguments{}, + NeedsServices: []string{otel_service.ServiceName}, + + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { + fact := vcenterreceiver.NewFactory() + return receiver.New(opts, fact, args.(Arguments)) + }, + }) +} + +type MetricConfig struct { + Enabled bool `river:"enabled,attr"` +} + +func (r *MetricConfig) Convert() map[string]interface{} { + if r == nil { + return nil + } + + return map[string]interface{}{ + "enabled": r.Enabled, + } +} + +type MetricsConfig struct { + VcenterClusterCPUEffective MetricConfig `river:"vcenter.cluster.cpu.effective,block,optional"` + VcenterClusterCPULimit MetricConfig `river:"vcenter.cluster.cpu.limit,block,optional"` + VcenterClusterHostCount MetricConfig `river:"vcenter.cluster.host.count,block,optional"` + VcenterClusterMemoryEffective MetricConfig `river:"vcenter.cluster.memory.effective,block,optional"` + VcenterClusterMemoryLimit MetricConfig `river:"vcenter.cluster.memory.limit,block,optional"` + VcenterClusterMemoryUsed MetricConfig `river:"vcenter.cluster.memory.used,block,optional"` + VcenterClusterVMCount MetricConfig `river:"vcenter.cluster.vm.count,block,optional"` + VcenterDatastoreDiskUsage MetricConfig `river:"vcenter.datastore.disk.usage,block,optional"` + VcenterDatastoreDiskUtilization MetricConfig `river:"vcenter.datastore.disk.utilization,block,optional"` + VcenterHostCPUUsage MetricConfig `river:"vcenter.host.cpu.usage,block,optional"` + VcenterHostCPUUtilization MetricConfig `river:"vcenter.host.cpu.utilization,block,optional"` + VcenterHostDiskLatencyAvg MetricConfig `river:"vcenter.host.disk.latency.avg,block,optional"` + VcenterHostDiskLatencyMax MetricConfig `river:"vcenter.host.disk.latency.max,block,optional"` + VcenterHostDiskThroughput MetricConfig `river:"vcenter.host.disk.throughput,block,optional"` + VcenterHostMemoryUsage MetricConfig `river:"vcenter.host.memory.usage,block,optional"` + VcenterHostMemoryUtilization MetricConfig `river:"vcenter.host.memory.utilization,block,optional"` + VcenterHostNetworkPacketCount MetricConfig `river:"vcenter.host.network.packet.count,block,optional"` + VcenterHostNetworkPacketErrors MetricConfig `river:"vcenter.host.network.packet.errors,block,optional"` + VcenterHostNetworkThroughput MetricConfig `river:"vcenter.host.network.throughput,block,optional"` + VcenterHostNetworkUsage MetricConfig `river:"vcenter.host.network.usage,block,optional"` + VcenterResourcePoolCPUShares MetricConfig `river:"vcenter.resource_pool.cpu.shares,block,optional"` + VcenterResourcePoolCPUUsage MetricConfig `river:"vcenter.resource_pool.cpu.usage,block,optional"` + VcenterResourcePoolMemoryShares MetricConfig `river:"vcenter.resource_pool.memory.shares,block,optional"` + VcenterResourcePoolMemoryUsage MetricConfig `river:"vcenter.resource_pool.memory.usage,block,optional"` + VcenterVMCPUUsage MetricConfig `river:"vcenter.vm.cpu.usage,block,optional"` + VcenterVMCPUUtilization MetricConfig `river:"vcenter.vm.cpu.utilization,block,optional"` + VcenterVMDiskLatencyAvg MetricConfig `river:"vcenter.vm.disk.latency.avg,block,optional"` + VcenterVMDiskLatencyMax MetricConfig `river:"vcenter.vm.disk.latency.max,block,optional"` + VcenterVMDiskThroughput MetricConfig `river:"vcenter.vm.disk.throughput,block,optional"` + VcenterVMDiskUsage MetricConfig `river:"vcenter.vm.disk.usage,block,optional"` + VcenterVMDiskUtilization MetricConfig `river:"vcenter.vm.disk.utilization,block,optional"` + VcenterVMMemoryBallooned MetricConfig `river:"vcenter.vm.memory.ballooned,block,optional"` + VcenterVMMemorySwapped MetricConfig `river:"vcenter.vm.memory.swapped,block,optional"` + VcenterVMMemorySwappedSsd MetricConfig `river:"vcenter.vm.memory.swapped_ssd,block,optional"` + VcenterVMMemoryUsage MetricConfig `river:"vcenter.vm.memory.usage,block,optional"` + VcenterVMMemoryUtilization MetricConfig `river:"vcenter.vm.memory.utilization,block,optional"` + VcenterVMNetworkPacketCount MetricConfig `river:"vcenter.vm.network.packet.count,block,optional"` + VcenterVMNetworkThroughput MetricConfig `river:"vcenter.vm.network.throughput,block,optional"` + VcenterVMNetworkUsage MetricConfig `river:"vcenter.vm.network.usage,block,optional"` +} + +func (args *MetricsConfig) Convert() map[string]interface{} { + if args == nil { + return nil + } + + return map[string]interface{}{ + "vcenter.cluster.cpu.effective": args.VcenterClusterCPUEffective.Convert(), + "vcenter.cluster.cpu.limit": args.VcenterClusterCPULimit.Convert(), + "vcenter.cluster.host.count": args.VcenterClusterHostCount.Convert(), + "vcenter.cluster.memory.effective": args.VcenterClusterMemoryEffective.Convert(), + "vcenter.cluster.memory.limit": args.VcenterClusterMemoryLimit.Convert(), + "vcenter.cluster.memory.used": args.VcenterClusterMemoryUsed.Convert(), + "vcenter.cluster.vm.count": args.VcenterClusterVMCount.Convert(), + "vcenter.datastore.disk.usage": args.VcenterDatastoreDiskUsage.Convert(), + "vcenter.datastore.disk.utilization": args.VcenterDatastoreDiskUtilization.Convert(), + "vcenter.host.cpu.usage": args.VcenterHostCPUUsage.Convert(), + "vcenter.host.cpu.utilization": args.VcenterHostCPUUtilization.Convert(), + "vcenter.host.disk.latency.avg": args.VcenterHostDiskLatencyAvg.Convert(), + "vcenter.host.disk.latency.max": args.VcenterHostDiskLatencyMax.Convert(), + "vcenter.host.disk.throughput": args.VcenterHostDiskThroughput.Convert(), + "vcenter.host.memory.usage": args.VcenterHostMemoryUsage.Convert(), + "vcenter.host.memory.utilization": args.VcenterHostMemoryUtilization.Convert(), + "vcenter.host.network.packet.count": args.VcenterHostNetworkPacketCount.Convert(), + "vcenter.host.network.packet.errors": args.VcenterHostNetworkPacketErrors.Convert(), + "vcenter.host.network.throughput": args.VcenterHostNetworkThroughput.Convert(), + "vcenter.host.network.usage": args.VcenterHostNetworkUsage.Convert(), + "vcenter.resource_pool.cpu.shares": args.VcenterResourcePoolCPUShares.Convert(), + "vcenter.resource_pool.cpu.usage": args.VcenterResourcePoolCPUUsage.Convert(), + "vcenter.resource_pool.memory.shares": args.VcenterResourcePoolMemoryShares.Convert(), + "vcenter.resource_pool.memory.usage": args.VcenterResourcePoolMemoryUsage.Convert(), + "vcenter.vm.cpu.usage": args.VcenterVMCPUUsage.Convert(), + "vcenter.vm.cpu.utilization": args.VcenterVMCPUUtilization.Convert(), + "vcenter.vm.disk.latency.avg": args.VcenterVMDiskLatencyAvg.Convert(), + "vcenter.vm.disk.latency.max": args.VcenterVMDiskLatencyMax.Convert(), + "vcenter.vm.disk.throughput": args.VcenterVMDiskThroughput.Convert(), + "vcenter.vm.disk.usage": args.VcenterVMDiskUsage.Convert(), + "vcenter.vm.disk.utilization": args.VcenterVMDiskUtilization.Convert(), + "vcenter.vm.memory.ballooned": args.VcenterVMMemoryBallooned.Convert(), + "vcenter.vm.memory.swapped": args.VcenterVMMemorySwapped.Convert(), + "vcenter.vm.memory.swapped_ssd": args.VcenterVMMemorySwappedSsd.Convert(), + "vcenter.vm.memory.usage": args.VcenterVMMemoryUsage.Convert(), + "vcenter.vm.memory.utilization": args.VcenterVMMemoryUtilization.Convert(), + "vcenter.vm.network.packet.count": args.VcenterVMNetworkPacketCount.Convert(), + "vcenter.vm.network.throughput": args.VcenterVMNetworkThroughput.Convert(), + "vcenter.vm.network.usage": args.VcenterVMNetworkUsage.Convert()} +} + +type ResourceAttributeConfig struct { + Enabled bool `river:"enabled,attr"` +} + +func (r *ResourceAttributeConfig) Convert() map[string]interface{} { + if r == nil { + return nil + } + + return map[string]interface{}{ + "enabled": r.Enabled, + } +} + +type ResourceAttributesConfig struct { + VcenterClusterName ResourceAttributeConfig `river:"vcenter.cluster.name,block,optional"` + VcenterDatastoreName ResourceAttributeConfig `river:"vcenter.datastore.name,block,optional"` + VcenterHostName ResourceAttributeConfig `river:"vcenter.host.name,block,optional"` + VcenterResourcePoolInventoryPath ResourceAttributeConfig `river:"vcenter.resource_pool.inventory_path,block,optional"` + VcenterResourcePoolName ResourceAttributeConfig `river:"vcenter.resource_pool.name,block,optional"` + VcenterVMID ResourceAttributeConfig `river:"vcenter.vm.id,block,optional"` + VcenterVMName ResourceAttributeConfig `river:"vcenter.vm.name,block,optional"` +} + +func (args *ResourceAttributesConfig) Convert() map[string]interface{} { + if args == nil { + return nil + } + + res := map[string]interface{}{ + "vcenter.cluster.name": args.VcenterClusterName.Convert(), + "vcenter.datastore.name": args.VcenterDatastoreName.Convert(), + "vcenter.host.name": args.VcenterHostName.Convert(), + "vcenter.resource_pool.inventory_path": args.VcenterResourcePoolInventoryPath.Convert(), + "vcenter.resource_pool.name": args.VcenterResourcePoolName.Convert(), + "vcenter.vm.id": args.VcenterVMID.Convert(), + "vcenter.vm.name": args.VcenterVMName.Convert(), + } + + return res +} + +type MetricsBuilderConfig struct { + Metrics MetricsConfig `river:"metrics,block,optional"` + ResourceAttributes ResourceAttributesConfig `river:"resource_attributes,block,optional"` +} + +func (args *MetricsBuilderConfig) Convert() map[string]interface{} { + if args == nil { + return nil + } + + res := map[string]interface{}{ + "metrics": args.Metrics.Convert(), + "resource_attributes": args.ResourceAttributes.Convert(), + } + + return res +} + +// Arguments configures the otelcol.receiver.vcenter component. +type Arguments struct { + Endpoint string `river:"endpoint,attr"` + Username string `river:"username,attr"` + Password rivertypes.Secret `river:"password,attr"` + + MetricsBuilderConfig MetricsBuilderConfig `river:",squash"` + + ScraperControllerArguments otelcol.ScraperControllerArguments `river:",squash"` + TLS otelcol.TLSClientArguments `river:"tls,block,optional"` + + // DebugMetrics configures component internal metrics. Optional. + DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` + + // Output configures where to send received data. Required. + Output *otelcol.ConsumerArguments `river:"output,block"` +} + +var _ receiver.Arguments = Arguments{} + +var ( + // DefaultArguments holds default values for Arguments. + DefaultArguments = Arguments{ + ScraperControllerArguments: otelcol.DefaultScraperControllerArguments, + MetricsBuilderConfig: MetricsBuilderConfig{ + Metrics: MetricsConfig{ + VcenterClusterCPUEffective: MetricConfig{Enabled: true}, + VcenterClusterCPULimit: MetricConfig{Enabled: true}, + VcenterClusterHostCount: MetricConfig{Enabled: true}, + VcenterClusterMemoryEffective: MetricConfig{Enabled: true}, + VcenterClusterMemoryLimit: MetricConfig{Enabled: true}, + VcenterClusterMemoryUsed: MetricConfig{Enabled: true}, + VcenterClusterVMCount: MetricConfig{Enabled: true}, + VcenterDatastoreDiskUsage: MetricConfig{Enabled: true}, + VcenterDatastoreDiskUtilization: MetricConfig{Enabled: true}, + VcenterHostCPUUsage: MetricConfig{Enabled: true}, + VcenterHostCPUUtilization: MetricConfig{Enabled: true}, + VcenterHostDiskLatencyAvg: MetricConfig{Enabled: true}, + VcenterHostDiskLatencyMax: MetricConfig{Enabled: true}, + VcenterHostDiskThroughput: MetricConfig{Enabled: true}, + VcenterHostMemoryUsage: MetricConfig{Enabled: true}, + VcenterHostMemoryUtilization: MetricConfig{Enabled: true}, + VcenterHostNetworkPacketCount: MetricConfig{Enabled: true}, + VcenterHostNetworkPacketErrors: MetricConfig{Enabled: true}, + VcenterHostNetworkThroughput: MetricConfig{Enabled: true}, + VcenterHostNetworkUsage: MetricConfig{Enabled: true}, + VcenterResourcePoolCPUShares: MetricConfig{Enabled: true}, + VcenterResourcePoolCPUUsage: MetricConfig{Enabled: true}, + VcenterResourcePoolMemoryShares: MetricConfig{Enabled: true}, + VcenterResourcePoolMemoryUsage: MetricConfig{Enabled: true}, + VcenterVMCPUUsage: MetricConfig{Enabled: true}, + VcenterVMCPUUtilization: MetricConfig{Enabled: true}, + VcenterVMDiskLatencyAvg: MetricConfig{Enabled: true}, + VcenterVMDiskLatencyMax: MetricConfig{Enabled: true}, + VcenterVMDiskThroughput: MetricConfig{Enabled: true}, + VcenterVMDiskUsage: MetricConfig{Enabled: true}, + VcenterVMDiskUtilization: MetricConfig{Enabled: true}, + VcenterVMMemoryBallooned: MetricConfig{Enabled: true}, + VcenterVMMemorySwapped: MetricConfig{Enabled: true}, + VcenterVMMemorySwappedSsd: MetricConfig{Enabled: true}, + VcenterVMMemoryUsage: MetricConfig{Enabled: true}, + VcenterVMMemoryUtilization: MetricConfig{Enabled: false}, + VcenterVMNetworkPacketCount: MetricConfig{Enabled: true}, + VcenterVMNetworkThroughput: MetricConfig{Enabled: true}, + VcenterVMNetworkUsage: MetricConfig{Enabled: true}, + }, + ResourceAttributes: ResourceAttributesConfig{ + VcenterClusterName: ResourceAttributeConfig{Enabled: true}, + VcenterDatastoreName: ResourceAttributeConfig{Enabled: true}, + VcenterHostName: ResourceAttributeConfig{Enabled: true}, + VcenterResourcePoolInventoryPath: ResourceAttributeConfig{Enabled: true}, + VcenterResourcePoolName: ResourceAttributeConfig{Enabled: true}, + VcenterVMID: ResourceAttributeConfig{Enabled: true}, + VcenterVMName: ResourceAttributeConfig{Enabled: true}, + }, + }, + } +) + +// SetToDefault implements river.Defaulter. +func (args *Arguments) SetToDefault() { + *args = DefaultArguments +} + +// Convert implements receiver.Arguments. +func (args Arguments) Convert() (otelcomponent.Config, error) { + cfg := args.MetricsBuilderConfig.Convert() + + var result vcenterreceiver.Config + err := mapstructure.Decode(cfg, &result) + + if err != nil { + return nil, err + } + + result.Endpoint = args.Endpoint + result.Username = args.Username + result.Password = configopaque.String(args.Password) + result.TLSClientSetting = *args.TLS.Convert() + result.ScraperControllerSettings = *args.ScraperControllerArguments.Convert() + + return &result, nil +} + +// Validate checks to see if the supplied config will work for the receiver +func (args Arguments) Validate() error { + res, err := url.Parse(args.Endpoint) + if err != nil { + return fmt.Errorf("unable to parse url %s: %w", args.Endpoint, err) + } + + if res.Scheme != "http" && res.Scheme != "https" { + return fmt.Errorf("url scheme must be http or https") + } + return nil +} + +// Extensions implements receiver.Arguments. +func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension { + return nil +} + +// Exporters implements receiver.Arguments. +func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component { + return nil +} + +// NextConsumers implements receiver.Arguments. +func (args Arguments) NextConsumers() *otelcol.ConsumerArguments { + return args.Output +} + +// DebugMetricsConfig implements receiver.Arguments. +func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { + return args.DebugMetrics +} diff --git a/component/otelcol/receiver/vcenter/vcenter_test.go b/component/otelcol/receiver/vcenter/vcenter_test.go new file mode 100644 index 000000000000..934d87d0798c --- /dev/null +++ b/component/otelcol/receiver/vcenter/vcenter_test.go @@ -0,0 +1,42 @@ +package vcenter + +import ( + "testing" + "time" + + "github.com/grafana/river" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" + "github.com/stretchr/testify/require" +) + +func TestArguments_UnmarshalRiver(t *testing.T) { + in := ` + endpoint = "http://localhost:1234" + username = "user" + password = "pass" + collection_interval = "2m" + + output { /* no-op */ } + ` + + var args Arguments + require.NoError(t, river.Unmarshal([]byte(in), &args)) + args.Convert() + ext, err := args.Convert() + require.NoError(t, err) + otelArgs, ok := (ext).(*vcenterreceiver.Config) + + require.True(t, ok) + + require.Equal(t, "user", otelArgs.Username) + require.Equal(t, "pass", string(otelArgs.Password)) + require.Equal(t, "http://localhost:1234", otelArgs.Endpoint) + + require.Equal(t, 2*time.Minute, otelArgs.ScraperControllerSettings.CollectionInterval) + require.Equal(t, time.Second, otelArgs.ScraperControllerSettings.InitialDelay) + require.Equal(t, 0*time.Second, otelArgs.ScraperControllerSettings.Timeout) + + require.Equal(t, true, otelArgs.Metrics.VcenterClusterCPUEffective.Enabled) + require.Equal(t, false, otelArgs.Metrics.VcenterVMMemoryUtilization.Enabled) + require.Equal(t, true, otelArgs.ResourceAttributes.VcenterClusterName.Enabled) +} diff --git a/docs/sources/flow/reference/components/otelcol.receiver.vcenter.md b/docs/sources/flow/reference/components/otelcol.receiver.vcenter.md new file mode 100644 index 000000000000..c5d9ef68563b --- /dev/null +++ b/docs/sources/flow/reference/components/otelcol.receiver.vcenter.md @@ -0,0 +1,143 @@ +--- +aliases: +- /docs/grafana-cloud/agent/flow/reference/components/otelcol.receiver.vcenter/ +- /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/otelcol.receiver.vcenter/ +- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/otelcol.receiver.vcenter/ +canonical: https://grafana.com/docs/agent/latest/flow/reference/components/otelcol.receiver.vcenter/ +title: otelcol.receiver.vcenter +description: Learn about otelcol.receiver.vcenter +labels: + stage: experimental +--- + +# otelcol.receiver.vcenter + +{{< docs/shared lookup="flow/stability/experimental.md" source="agent" version="" >}} + +`otelcol.receiver.vcenter` accepts metrics from a +vCenter or ESXi host running VMware vSphere APIs and +forwards it to other `otelcol.*` components. + +> **NOTE**: `otelcol.receiver.vcenter` is a wrapper over the upstream +> OpenTelemetry Collector `vcenter` receiver from the `otelcol-contrib` +> distribution. Bug reports or feature requests will be redirected to the +> upstream repository, if necessary. + +Multiple `otelcol.receiver.vcenter` components can be specified by giving them +different labels. + +The full list of metrics that can be collected can be found in [vcenter receiver documentation][vcenter metrics]. + +[vcenter metrics]: https://github.com/open-telemetry/opentelemetry-collector/blob/{{< param "OTEL_VERSION" >}}/receiver/vcenterreceiver/documentation.md + +## Prerequisites + +This receiver has been built to support ESXi and vCenter versions: + +- 7.5 +- 7.0 +- 6.7 + +A “Read Only” user assigned to a vSphere with permissions to the vCenter server, cluster and all subsequent resources being monitored must be specified in order for the receiver to retrieve information about them. + +## Usage + +```river +otelcol.receiver.vcenter "LABEL" { + endpoint = "VCENTER_ENDPOINT" + username = "VCENTER_USERNAME" + password = "VCENTER_PASSWORD" + + output { + metrics = [...] + } +} +``` + +## Arguments + +`otelcol.receiver.vcenter` supports the following arguments: + + +Name | Type | Description | Default | Required +---- | ---- | ----------- | ------- | -------- +`endpoint` | `string` | Endpoint to a vCenter Server or ESXi host which has the SDK path enabled. | | yes +`username` | `string` | Username to use for authentication. | | yes +`password` | `string` | Password to use for authentication. | | yes +`collection_interval` | `duration` | Defines how often to collect metrics. | `"1m"` | no +`initial_delay` | `duration` | Defines how long this receiver waits before starting. | `"1s"` | no +`timeout` | `duration` | Defines the timeout for the underlying HTTP client. | `"0s"` | no + +`endpoint` has the format `://`. For example, `https://vcsa.hostname.localnet`. + +## Blocks + +The following blocks are supported inside the definition of +`otelcol.receiver.vcenter`: + +Hierarchy | Block | Description | Required +--------- | ----- | ----------- | -------- +tls | [tls][] | Configures TLS for the HTTP client. | no +debug_metrics | [debug_metrics][] | Configures the metrics that this component generates to monitor its state. | no +output | [output][] | Configures where to send received telemetry data. | yes + +[tls]: #tls-block +[debug_metrics]: #debug_metrics-block +[output]: #output-block + +### tls block + +The `tls` block configures TLS settings used for a server. If the `tls` block +isn't provided, TLS won't be used for connections to the server. + +{{< docs/shared lookup="flow/reference/components/otelcol-tls-config-block.md" source="agent" version="" >}} + +### debug_metrics block + +{{< docs/shared lookup="flow/reference/components/otelcol-debug-metrics-block.md" source="agent" version="" >}} + +### output block + +{{< docs/shared lookup="flow/reference/components/output-block.md" source="agent" version="" >}} + +## Exported fields + +`otelcol.receiver.vcenter` does not export any fields. + +## Component health + +`otelcol.receiver.vcenter` is only reported as unhealthy if given an invalid +configuration. + +## Debug information + +`otelcol.receiver.vcenter` does not expose any component-specific debug +information. + +## Example + +This example forwards received telemetry data through a batch processor before +finally sending it to an OTLP-capable endpoint: + +```river +otelcol.receiver.vcenter "default" { + endpoint = "http://localhost:15672" + username = "otelu" + password = "password" + + output { + metrics = [otelcol.processor.batch.default.input] + } +} + +otelcol.processor.batch "default" { + output { + metrics = [otelcol.exporter.otlp.default.input] + } +} + +otelcol.exporter.otlp "default" { + client { + endpoint = env("OTLP_ENDPOINT") + } +} diff --git a/docs/sources/flow/reference/components/prometheus.exporter.vsphere.md b/docs/sources/flow/reference/components/prometheus.exporter.vsphere.md index 166226a27717..f9231788ef8e 100644 --- a/docs/sources/flow/reference/components/prometheus.exporter.vsphere.md +++ b/docs/sources/flow/reference/components/prometheus.exporter.vsphere.md @@ -5,14 +5,19 @@ aliases: - /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/prometheus.exporter.vsphere/ - /docs/grafana-cloud/send-data/agent/flow/reference/components/prometheus.exporter.vsphere/ canonical: https://grafana.com/docs/agent/latest/flow/reference/components/prometheus.exporter.vsphere/ -description: Learn about prometheus.exporter.vsphere title: prometheus.exporter.vsphere +description: Learn about prometheus.exporter.vsphere --- # prometheus.exporter.vsphere The `prometheus.exporter.vsphere` component embeds [`vmware_exporter`](https://github.com/grafana/vmware_exporter) to collect vSphere metrics +> **NOTE**: We recommend to use [otelcol.receiver.vcenter][] instead. + +[otelcol.receiver.vcenter]: {{< relref "./otelcol.receiver.vcenter.md" >}} + + ## Usage ```river diff --git a/go.mod b/go.mod index 2602e4922d07..891de83235af 100644 --- a/go.mod +++ b/go.mod @@ -559,7 +559,7 @@ require ( github.com/vertica/vertica-sql-go v1.3.0 // indirect github.com/vishvananda/netlink v1.2.1-beta.2 // indirect github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect - github.com/vmware/govmomi v0.27.2 // indirect + github.com/vmware/govmomi v0.32.0 // indirect github.com/vultr/govultr/v2 v2.17.2 // indirect github.com/willf/bitset v1.1.11 // indirect github.com/willf/bloom v2.0.3+incompatible // indirect @@ -615,6 +615,7 @@ require ( github.com/githubexporter/github-exporter v0.0.0-20231025122338-656e7dc33fe7 github.com/natefinch/atomic v1.0.1 github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.87.0 + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.42.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 ) diff --git a/go.sum b/go.sum index 573217dc64a4..0384745ab682 100644 --- a/go.sum +++ b/go.sum @@ -242,7 +242,6 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.1.0 h1:hu20UpgZneBhQ3ZvwiOGlqJSKIosin2Rd5wAKUHEO/k= github.com/Workiva/go-datastructures v1.1.0/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= -github.com/a8m/tree v0.0.0-20210115125333-10a5fd5b637d/go.mod h1:FSdwKX97koS5efgm8WevNf7XS3PqtyFkKDDXrz778cg= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af h1:DBNMBMuMiWYu0b+8KMJuWmfCkcxl09JwdlqwDZZ6U14= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= @@ -399,6 +398,8 @@ github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA= +github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw= +github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw= github.com/beevik/ntp v1.3.0 h1:/w5VhpW5BGKS37vFm1p9oVk/t4HnnkKZAZIubHM6F7Q= github.com/beevik/ntp v1.3.0/go.mod h1:vD6h1um4kzXpqmLTuu0cCLcC+NfvC0IC+ltmEDA8E78= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= @@ -540,7 +541,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE= github.com/davidmparrott/kafka_exporter/v2 v2.0.1 h1:nGn+MKV8z08NK4xqcYSa3fBCs/VPVesT/5kboFWJaiE= github.com/davidmparrott/kafka_exporter/v2 v2.0.1/go.mod h1:n3ho8mZ5tZcmr8NAu/SjQHY61CDTqXtrACcEYwLXv4Y= github.com/denisenkom/go-mssqldb v0.0.0-20180620032804-94c9c97e8c9f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= @@ -1803,6 +1803,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusrec github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver v0.87.0/go.mod h1:LIGa2oqb+geqkmWvteeDjzulK1PfDYCY8Jp6pI0ey2A= github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.87.0 h1:fwmow4M0aJUsmY9DGUMe6yykd0TvgB6PpLS+Z590R5s= github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.87.0/go.mod h1:ZLfpGguza42G+SwGEZ5/plr1wa3D7GA7I6KJyARgHPA= +github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0 h1:TI5m4trLA3cVMQSRyxU14MzCzHXDk56+sc+9TY01uw0= +github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0/go.mod h1:IA/xIUE0Fl8lc7hkEOkVyYcTF7sE7AGawI9s8ipqRKc= github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.87.0 h1:0DeNqM3fhNYPsfmPbaZ1PyBJ2vtOSFpMGadRKvryXfs= github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.87.0/go.mod h1:tSxkxxWCcGh/vh1mHflhQTlwulkwWM1yyEABa6DXSmY= github.com/openconfig/gnmi v0.0.0-20180912164834-33a1865c3029/go.mod h1:t+O9It+LKzfOAhKTT5O0ehDix+MTqbtT0T9t+7zzOvc= @@ -2219,9 +2221,8 @@ github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1 github.com/vjeantet/grok v1.0.0/go.mod h1:/FWYEVYekkm+2VjcFmO9PufDU5FgXHUz9oy2EGqmQBo= github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/vmware/govmomi v0.19.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/vmware/govmomi v0.27.2 h1:Ecooqg069gUbl5EuWYwcrvzRqMkah9J8BXaf9HCEGVM= -github.com/vmware/govmomi v0.27.2/go.mod h1:daTuJEcQosNMXYJOeku0qdBJP9SOLLWB3Mqz8THtv6o= -github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk= +github.com/vmware/govmomi v0.32.0 h1:Rsdi/HAX5Ebf9Byp/FvBir4sfM7yP5DBUeRlbC6vLBo= +github.com/vmware/govmomi v0.32.0/go.mod h1:JA63Pg0SgQcSjk+LuPzjh3rJdcWBo/ZNCIwbb1qf2/0= github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs= github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI= github.com/wavefronthq/wavefront-sdk-go v0.9.2/go.mod h1:hQI6y8M9OtTCtc0xdwh+dCER4osxXdEAeCpacjpDZEU=