forked from grafana/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flow: Add otelcol.receiver.vcenter component (grafana#5715)
Co-authored-by: Paulin Todev <[email protected]>
- Loading branch information
Showing
9 changed files
with
590 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
143 changes: 143 additions & 0 deletions
143
docs/sources/flow/reference/components/otelcol.receiver.vcenter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="<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 `<protocol>://<hostname>`. 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="<AGENT VERSION>" >}} | ||
|
||
### debug_metrics block | ||
|
||
{{< docs/shared lookup="flow/reference/components/otelcol-debug-metrics-block.md" source="agent" version="<AGENT VERSION>" >}} | ||
|
||
### output block | ||
|
||
{{< docs/shared lookup="flow/reference/components/output-block.md" source="agent" version="<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") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters