Skip to content

Commit

Permalink
wire up vsphere exporter for static to integrations v2 converter
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski committed Dec 11, 2023
1 parent 9bd17da commit 6094ba1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/alecthomas/units"
"github.com/grafana/agent/component/common/loki"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/component/faro/receiver"
"github.com/grafana/agent/component/otelcol"
"github.com/grafana/agent/converter/diag"
Expand All @@ -15,7 +14,7 @@ import (
"github.com/grafana/river/scanner"
)

func (b *IntegrationsConfigBuilder) appendAppAgentReceiverV2(config *app_agent_receiver_v2.Config) discovery.Exports {
func (b *IntegrationsConfigBuilder) appendAppAgentReceiverV2(config *app_agent_receiver_v2.Config) {
args := toAppAgentReceiverV2(config)

compLabel, err := scanner.SanitizeIdentifier(b.formatJobName(config.Name(), nil))
Expand All @@ -28,8 +27,6 @@ func (b *IntegrationsConfigBuilder) appendAppAgentReceiverV2(config *app_agent_r
compLabel,
args,
))

return discovery.Exports{}
}

func toAppAgentReceiverV2(config *app_agent_receiver_v2.Config) *receiver.Arguments {
Expand Down
6 changes: 5 additions & 1 deletion converter/internal/staticconvert/internal/build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
common_v2 "github.com/grafana/agent/pkg/integrations/v2/common"
"github.com/grafana/agent/pkg/integrations/v2/metricsutils"
snmp_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/snmp_exporter"
vmware_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/vmware_exporter"
"github.com/grafana/agent/pkg/integrations/windows_exporter"
"github.com/grafana/river/scanner"
"github.com/grafana/river/token/builder"
Expand Down Expand Up @@ -219,14 +220,17 @@ func (b *IntegrationsConfigBuilder) appendV2Integrations() {
exports = b.appendApacheExporterV2(itg)
commonConfig = itg.Common
case *app_agent_receiver_v2.Config:
exports = b.appendAppAgentReceiverV2(itg)
b.appendAppAgentReceiverV2(itg)
commonConfig = itg.Common
case *blackbox_exporter_v2.Config:
exports = b.appendBlackboxExporterV2(itg)
commonConfig = itg.Common
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.ConfigShim:
commonConfig = itg.Common
switch v1_itg := itg.Orig.(type) {
Expand Down
25 changes: 25 additions & 0 deletions converter/internal/staticconvert/internal/build/vmware_exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package build

import (
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/component/prometheus/exporter/vsphere"
vmware_exporter_v2 "github.com/grafana/agent/pkg/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,
}
}
21 changes: 21 additions & 0 deletions converter/internal/staticconvert/testdata-v2/integrations_v2.river
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,24 @@ 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"
}
}

prometheus.scrape "integrations_vsphere" {
targets = discovery.relabel.integrations_vsphere.output
forward_to = [prometheus.remote_write.metrics_default.receiver]
job_name = "integrations/vsphere"
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,14 @@ integrations:
scrape_timeout: 1m
statsd:
autoscrape:
metrics_instance: "default"
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
2 changes: 2 additions & 0 deletions converter/internal/staticconvert/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
blackbox_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/blackbox_exporter"
"github.com/grafana/agent/pkg/integrations/v2/metricsutils"
snmp_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/snmp_exporter"
vmware_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/vmware_exporter"
"github.com/grafana/agent/pkg/integrations/windows_exporter"
"github.com/grafana/agent/pkg/logs"
"github.com/grafana/agent/pkg/metrics"
Expand Down Expand Up @@ -171,6 +172,7 @@ func validateIntegrationsV2(integrationsConfig *v2.SubsystemOptions) diag.Diagno
diags.AddAll(common.ValidateSupported(common.NotEquals, itg.TracesInstance, "", "app_agent_receiver traces_instance", ""))
case *blackbox_exporter_v2.Config:
case *snmp_exporter_v2.Config:
case *vmware_exporter_v2.Config:
case *metricsutils.ConfigShim:
switch v1_itg := itg.Orig.(type) {
case *azure_exporter.Config:
Expand Down

0 comments on commit 6094ba1

Please sign in to comment.