From 3337557eab402cc4de85c93f3adfe9134aa86a98 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Fri, 15 Mar 2024 15:03:13 -0400 Subject: [PATCH] Remove prometheus.exporter.vsphere (#35) Co-authored-by: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com> --- .../sources/reference/compatibility/_index.md | 1 - .../components/prometheus.exporter.vsphere.md | 102 ------------------ docs/sources/release-notes.md | 2 +- internal/component/all/all.go | 1 - .../prometheus/exporter/vsphere/vsphere.go | 65 ----------- .../exporter/vsphere/vsphere_test.go | 59 ---------- .../staticconvert/internal/build/builder.go | 4 - .../internal/build/vmware_exporter.go | 25 ----- .../testdata-v2/integrations_v2.river | 26 ----- .../testdata-v2/integrations_v2.yaml | 14 +-- .../testdata-v2/unsupported.diags | 3 +- .../testdata-v2/unsupported.yaml | 12 ++- .../internal/staticconvert/validate.go | 5 + 13 files changed, 21 insertions(+), 298 deletions(-) delete mode 100644 docs/sources/reference/components/prometheus.exporter.vsphere.md delete mode 100644 internal/component/prometheus/exporter/vsphere/vsphere.go delete mode 100644 internal/component/prometheus/exporter/vsphere/vsphere_test.go delete mode 100644 internal/converter/internal/staticconvert/internal/build/vmware_exporter.go diff --git a/docs/sources/reference/compatibility/_index.md b/docs/sources/reference/compatibility/_index.md index d3d3154f49..c34d9281bf 100644 --- a/docs/sources/reference/compatibility/_index.md +++ b/docs/sources/reference/compatibility/_index.md @@ -105,7 +105,6 @@ The following components, grouped by namespace, _export_ Targets. - [prometheus.exporter.squid](../components/prometheus.exporter.squid) - [prometheus.exporter.statsd](../components/prometheus.exporter.statsd) - [prometheus.exporter.unix](../components/prometheus.exporter.unix) -- [prometheus.exporter.vsphere](../components/prometheus.exporter.vsphere) - [prometheus.exporter.windows](../components/prometheus.exporter.windows) {{< /collapse >}} diff --git a/docs/sources/reference/components/prometheus.exporter.vsphere.md b/docs/sources/reference/components/prometheus.exporter.vsphere.md deleted file mode 100644 index 869cc61a75..0000000000 --- a/docs/sources/reference/components/prometheus.exporter.vsphere.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -canonical: https://grafana.com/docs/alloy/latest/reference/components/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 - -{{< admonition type="note" >}} -We recommend to use [otelcol.receiver.vcenter][] instead. - -[otelcol.receiver.vcenter]: ./otelcol.receiver.vcenter/ -{{< /admonition >}} - -## Usage - -```river -prometheus.exporter.vsphere "LABEL" { -} -``` - -## Arguments - -You can use the following arguments to configure the exporter's behavior. -Omitted fields take their default values. - -| Name | Type | Description | Default | Required | -| ---------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- | -| `vsphere_url` | `string` | The url of the vCenter endpoint SDK | | no | -| `vsphere_user` | `string` | vCenter username. | | no | -| `vsphere_password` | `secret` | vCenter password. | | no | -| `request_chunk_size` | `int` | Number of managed objects to include in each request to vsphere when fetching performance counters. | `256` | no | -| `collect_concurrency` | `int` | Number of concurrent requests to vSphere when fetching performance counters. | `8` | no | -| `discovery_interval` | `duration` | Interval on which to run vSphere managed object discovery. | `0` | no | -| `enable_exporter_metrics` | `boolean` | Enable the exporter metrics. | `true` | no | - -- Setting `discovery_interval` to a non-zero value will result in object discovery running in the background. Each scrape will use object data gathered during the last discovery. When this value is 0, object discovery occurs per scrape. - - -## Exported fields - -{{< docs/shared lookup="reference/components/exporter-component-exports.md" source="alloy" version="" >}} - -## Component health - -`prometheus.exporter.vsphere` is only reported as unhealthy if given -an invalid configuration. In those cases, exported fields retain their last -healthy values. - -## Debug information - -`prometheus.exporter.vsphere` does not expose any component-specific -debug information. - -## Debug metrics - -`prometheus.exporter.vsphere` does not expose any component-specific -debug metrics. - -## Example - -This example uses a [`prometheus.scrape` component][scrape] to collect metrics -from `prometheus.exporter.vsphere`: - -```river -prometheus.exporter.vsphere "example" { - vsphere_url = "https://127.0.0.1:8989/sdk" - vsphere_user = "user" - vsphere_password = "pass" -} - -// Configure a prometheus.scrape component to collect vsphere metrics. -prometheus.scrape "demo" { - targets = prometheus.exporter.vsphere.example.targets - forward_to = [ prometheus.remote_write.default.receiver ] -} - -prometheus.remote_write "default" { - endpoint { - url = "REMOTE_WRITE_URL" - } -} -``` - -[scrape]: ../prometheus.scrape/ - - - -## Compatible components - -`prometheus.exporter.vsphere` has exports that can be consumed by the following components: - -- Components that consume [Targets](../../compatibility/#targets-consumers) - -{{< admonition type="note" >}} -Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. -Refer to the linked documentation for more details. -{{< /admonition >}} - - diff --git a/docs/sources/release-notes.md b/docs/sources/release-notes.md index a665a5010c..2d282a0235 100644 --- a/docs/sources/release-notes.md +++ b/docs/sources/release-notes.md @@ -12,4 +12,4 @@ The release notes provide information about deprecations and breaking changes in For a complete list of changes to {{< param "PRODUCT_ROOT_NAME" >}}, with links to pull requests and related issues when available, refer to the [Changelog][]. -[Changelog]: https://github.com/grafana/alloy/blob/main/CHANGELOG.md \ No newline at end of file +[Changelog]: https://github.com/grafana/alloy/blob/main/CHANGELOG.md diff --git a/internal/component/all/all.go b/internal/component/all/all.go index 7cc147ea80..3369357d50 100644 --- a/internal/component/all/all.go +++ b/internal/component/all/all.go @@ -117,7 +117,6 @@ import ( _ "github.com/grafana/agent/internal/component/prometheus/exporter/squid" // Import prometheus.exporter.squid _ "github.com/grafana/agent/internal/component/prometheus/exporter/statsd" // Import prometheus.exporter.statsd _ "github.com/grafana/agent/internal/component/prometheus/exporter/unix" // Import prometheus.exporter.unix - _ "github.com/grafana/agent/internal/component/prometheus/exporter/vsphere" // Import prometheus.exporter.vsphere _ "github.com/grafana/agent/internal/component/prometheus/exporter/windows" // Import prometheus.exporter.windows _ "github.com/grafana/agent/internal/component/prometheus/operator/podmonitors" // Import prometheus.operator.podmonitors _ "github.com/grafana/agent/internal/component/prometheus/operator/probes" // Import prometheus.operator.probes diff --git a/internal/component/prometheus/exporter/vsphere/vsphere.go b/internal/component/prometheus/exporter/vsphere/vsphere.go deleted file mode 100644 index aeb35d1dd8..0000000000 --- a/internal/component/prometheus/exporter/vsphere/vsphere.go +++ /dev/null @@ -1,65 +0,0 @@ -package vsphere - -import ( - "time" - - "github.com/grafana/agent/internal/component" - "github.com/grafana/agent/internal/component/prometheus/exporter" - "github.com/grafana/agent/internal/featuregate" - "github.com/grafana/agent/internal/static/integrations" - "github.com/grafana/agent/internal/static/integrations/vmware_exporter" - "github.com/grafana/river/rivertypes" - config_util "github.com/prometheus/common/config" -) - -func init() { - component.Register(component.Registration{ - Name: "prometheus.exporter.vsphere", - Stability: featuregate.StabilityStable, - Args: Arguments{}, - Exports: exporter.Exports{}, - - Build: exporter.New(createExporter, "vsphere"), - }) -} - -func createExporter(opts component.Options, args component.Arguments, defaultInstanceKey string) (integrations.Integration, string, error) { - a := args.(Arguments) - return integrations.NewIntegrationWithInstanceKey(opts.Logger, a.Convert(), defaultInstanceKey) -} - -// DefaultArguments holds the default settings for the vsphere exporter -var DefaultArguments = Arguments{ - ChunkSize: 256, - CollectConcurrency: 8, - ObjectDiscoveryInterval: 0, - EnableExporterMetrics: true, -} - -// Arguments controls the vsphere exporter. -type Arguments struct { - ChunkSize int `river:"request_chunk_size,attr,optional"` - CollectConcurrency int `river:"collect_concurrency,attr,optional"` - VSphereURL string `river:"vsphere_url,attr,optional"` - VSphereUser string `river:"vsphere_user,attr,optional"` - VSpherePass rivertypes.Secret `river:"vsphere_password,attr,optional"` - ObjectDiscoveryInterval time.Duration `river:"discovery_interval,attr,optional"` - EnableExporterMetrics bool `river:"enable_exporter_metrics,attr,optional"` -} - -// SetToDefault implements river.Defaulter. -func (a *Arguments) SetToDefault() { - *a = DefaultArguments -} - -func (a *Arguments) Convert() *vmware_exporter.Config { - return &vmware_exporter.Config{ - ChunkSize: a.ChunkSize, - CollectConcurrency: a.CollectConcurrency, - VSphereURL: a.VSphereURL, - VSphereUser: a.VSphereUser, - VSpherePass: config_util.Secret(a.VSpherePass), - ObjectDiscoveryInterval: a.ObjectDiscoveryInterval, - EnableExporterMetrics: a.EnableExporterMetrics, - } -} diff --git a/internal/component/prometheus/exporter/vsphere/vsphere_test.go b/internal/component/prometheus/exporter/vsphere/vsphere_test.go deleted file mode 100644 index edf5ebfa89..0000000000 --- a/internal/component/prometheus/exporter/vsphere/vsphere_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package vsphere - -import ( - "testing" - - "github.com/grafana/agent/internal/static/integrations/vmware_exporter" - "github.com/grafana/river" - "github.com/stretchr/testify/require" -) - -func TestRiverUnmarshal(t *testing.T) { - riverConfig := ` - request_chunk_size = 256 - collect_concurrency = 8 - vsphere_url = "https://localhost:443/sdk" - vsphere_user = "user" - vsphere_password = "pass" - discovery_interval = 0 - enable_exporter_metrics = true - ` - var args Arguments - err := river.Unmarshal([]byte(riverConfig), &args) - - require.NoError(t, err) - expected := Arguments{ - ChunkSize: 256, - CollectConcurrency: 8, - VSphereURL: "https://localhost:443/sdk", - VSphereUser: "user", - VSpherePass: "pass", - ObjectDiscoveryInterval: 0, - EnableExporterMetrics: true, - } - require.Equal(t, expected, args) -} - -func TestRiverConvert(t *testing.T) { - orig := Arguments{ - ChunkSize: 256, - CollectConcurrency: 8, - VSphereURL: "https://localhost:443/sdk", - VSphereUser: "user", - VSpherePass: "pass", - ObjectDiscoveryInterval: 0, - EnableExporterMetrics: true, - } - converted := orig.Convert() - expected := vmware_exporter.Config{ - ChunkSize: 256, - CollectConcurrency: 8, - VSphereURL: "https://localhost:443/sdk", - VSphereUser: "user", - VSpherePass: "pass", - ObjectDiscoveryInterval: 0, - EnableExporterMetrics: true, - } - - require.Equal(t, expected, *converted) -} diff --git a/internal/converter/internal/staticconvert/internal/build/builder.go b/internal/converter/internal/staticconvert/internal/build/builder.go index 68e35d2880..1f8c695031 100644 --- a/internal/converter/internal/staticconvert/internal/build/builder.go +++ b/internal/converter/internal/staticconvert/internal/build/builder.go @@ -45,7 +45,6 @@ import ( eventhandler_v2 "github.com/grafana/agent/internal/static/integrations/v2/eventhandler" metricsutils_v2 "github.com/grafana/agent/internal/static/integrations/v2/metricsutils" snmp_exporter_v2 "github.com/grafana/agent/internal/static/integrations/v2/snmp_exporter" - vmware_exporter_v2 "github.com/grafana/agent/internal/static/integrations/v2/vmware_exporter" "github.com/grafana/agent/internal/static/integrations/windows_exporter" "github.com/grafana/river/scanner" "github.com/grafana/river/token/builder" @@ -239,9 +238,6 @@ func (b *IntegrationsConfigBuilder) appendV2Integrations() { case *snmp_exporter_v2.Config: exports = b.appendSnmpExporterV2(itg) commonConfig = itg.Common - case *vmware_exporter_v2.Config: - exports = b.appendVmwareExporterV2(itg) - commonConfig = itg.Common case *metricsutils_v2.ConfigShim: commonConfig = itg.Common switch v1_itg := itg.Orig.(type) { diff --git a/internal/converter/internal/staticconvert/internal/build/vmware_exporter.go b/internal/converter/internal/staticconvert/internal/build/vmware_exporter.go deleted file mode 100644 index 656395b668..0000000000 --- a/internal/converter/internal/staticconvert/internal/build/vmware_exporter.go +++ /dev/null @@ -1,25 +0,0 @@ -package build - -import ( - "github.com/grafana/agent/internal/component/discovery" - "github.com/grafana/agent/internal/component/prometheus/exporter/vsphere" - vmware_exporter_v2 "github.com/grafana/agent/internal/static/integrations/v2/vmware_exporter" - "github.com/grafana/river/rivertypes" -) - -func (b *IntegrationsConfigBuilder) appendVmwareExporterV2(config *vmware_exporter_v2.Config) discovery.Exports { - args := toVmwareExporter(config) - return b.appendExporterBlock(args, config.Name(), nil, "vsphere") -} - -func toVmwareExporter(config *vmware_exporter_v2.Config) *vsphere.Arguments { - return &vsphere.Arguments{ - ChunkSize: config.ChunkSize, - CollectConcurrency: config.CollectConcurrency, - VSphereURL: config.VSphereURL, - VSphereUser: config.VSphereUser, - VSpherePass: rivertypes.Secret(config.VSpherePass), - ObjectDiscoveryInterval: config.ObjectDiscoveryInterval, - EnableExporterMetrics: config.EnableExporterMetrics, - } -} diff --git a/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.river b/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.river index c609330be6..f7c22ade64 100644 --- a/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.river +++ b/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.river @@ -762,29 +762,3 @@ prometheus.scrape "integrations_snmp" { forward_to = [prometheus.remote_write.metrics_default.receiver] job_name = "integrations/snmp" } - -prometheus.exporter.vsphere "integrations_vsphere" { - vsphere_url = "https://127.0.0.1:8989/sdk" - vsphere_user = "user" - vsphere_password = "pass" -} - -discovery.relabel "integrations_vsphere" { - targets = prometheus.exporter.vsphere.integrations_vsphere.targets - - rule { - target_label = "instance" - replacement = "vsphere" - } - - rule { - target_label = "job" - replacement = "integrations/vsphere" - } -} - -prometheus.scrape "integrations_vsphere" { - targets = discovery.relabel.integrations_vsphere.output - forward_to = [prometheus.remote_write.metrics_default.receiver] - job_name = "integrations/vsphere" -} diff --git a/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml b/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml index cd0c497d15..7a5a4ee730 100644 --- a/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml +++ b/internal/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml @@ -1,7 +1,7 @@ server: log_level: ${SOME_ENVIRONMENT_VARIABLE:='debug'} log_format: json - + metrics: global: remote_write: @@ -182,7 +182,7 @@ integrations: oracledb_configs: - connection_string: oracle://user:password@localhost:1521/orcl.localnet postgres_configs: - - data_source_names: + - data_source_names: - postgres://postgres:password@localhost:5432/postgres?sslmode=disable autoscrape: relabel_configs: @@ -228,13 +228,3 @@ integrations: statsd: autoscrape: metrics_instance: "default" - vsphere_configs: - - vsphere_url: https://127.0.0.1:8989/sdk - vsphere_user: user - vsphere_password: pass - request_chunk_size: 256 - collect_concurrency: 8 - instance: vsphere - autoscrape: - enable: true - metrics_instance: default \ No newline at end of file diff --git a/internal/converter/internal/staticconvert/testdata-v2/unsupported.diags b/internal/converter/internal/staticconvert/testdata-v2/unsupported.diags index 48eae120a2..85fb306a8b 100644 --- a/internal/converter/internal/staticconvert/testdata-v2/unsupported.diags +++ b/internal/converter/internal/staticconvert/testdata-v2/unsupported.diags @@ -3,4 +3,5 @@ (Error) The converter does not support converting the provided eventhandler flush_interval config: this field is not configurable in flow mode (Warning) The eventhandler cache_path is unnecessary in flow mode because the storage path is governed by the --storage.path cmd argument and is always local to the component. (Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. -(Error) The converter does not support converting the provided app_agent_receiver traces_instance config. \ No newline at end of file +(Error) The converter does not support converting the provided app_agent_receiver traces_instance config. +(Error) Support for the vsphere integration has been removed in Grafana Alloy v1.0, and conversion will not be performed.\nTo achieve similar functionality, consider creating an otelcol.receiver.vcenter component and converting generated metrics to a Prometheus pipeline using otelcol.exporter.prometheus. diff --git a/internal/converter/internal/staticconvert/testdata-v2/unsupported.yaml b/internal/converter/internal/staticconvert/testdata-v2/unsupported.yaml index dfce6ed22e..25a438ee01 100644 --- a/internal/converter/internal/staticconvert/testdata-v2/unsupported.yaml +++ b/internal/converter/internal/staticconvert/testdata-v2/unsupported.yaml @@ -25,4 +25,14 @@ integrations: logs_instance: "log_config" send_timeout: 30 informer_resync: 30 - flush_interval: 30 \ No newline at end of file + flush_interval: 30 + vsphere_configs: + - vsphere_url: https://127.0.0.1:8989/sdk + vsphere_user: user + vsphere_password: pass + request_chunk_size: 256 + collect_concurrency: 8 + instance: vsphere + autoscrape: + enable: true + metrics_instance: default diff --git a/internal/converter/internal/staticconvert/validate.go b/internal/converter/internal/staticconvert/validate.go index 024b57b182..a703dd5a43 100644 --- a/internal/converter/internal/staticconvert/validate.go +++ b/internal/converter/internal/staticconvert/validate.go @@ -175,6 +175,11 @@ func validateIntegrationsV2(integrationsConfig *v2.SubsystemOptions) diag.Diagno case *eventhandler_v2.Config: case *snmp_exporter_v2.Config: case *vmware_exporter_v2.Config: + diags.AddWithDetail( + diag.SeverityLevelError, + "Support for the vsphere integration has been removed in Grafana Alloy v1.0, and conversion will not be performed.", + "To achieve similar functionality, consider creating an otelcol.receiver.vcenter component and converting generated metrics to a Prometheus pipeline using otelcol.exporter.prometheus.", + ) case *metricsutils_v2.ConfigShim: switch v1_itg := itg.Orig.(type) { case *azure_exporter.Config: