diff --git a/converter/internal/staticconvert/internal/build/builder.go b/converter/internal/staticconvert/internal/build/builder.go index 2e95f0a6eadd..8d68f9371946 100644 --- a/converter/internal/staticconvert/internal/build/builder.go +++ b/converter/internal/staticconvert/internal/build/builder.go @@ -143,7 +143,7 @@ func (b *IntegrationsConfigBuilder) appendV1Integrations() { case *snmp_exporter.Config: exports = b.appendSnmpExporter(itg) case *snowflake_exporter.Config: - exports = b.appendSnowflakeExporter(itg) + exports = b.appendSnowflakeExporter(itg, nil) case *squid_exporter.Config: exports = b.appendSquidExporter(itg) case *statsd_exporter.Config: @@ -252,6 +252,8 @@ func (b *IntegrationsConfigBuilder) appendV2Integrations() { exports = b.appendProcessExporter(v1_itg, itg.Common.InstanceKey) case *redis_exporter.Config: exports = b.appendRedisExporter(v1_itg, itg.Common.InstanceKey) + case *snowflake_exporter.Config: + exports = b.appendSnowflakeExporter(v1_itg, itg.Common.InstanceKey) } } diff --git a/converter/internal/staticconvert/internal/build/snowflake_exporter.go b/converter/internal/staticconvert/internal/build/snowflake_exporter.go index 34f605564c35..ed0f10ff1c1e 100644 --- a/converter/internal/staticconvert/internal/build/snowflake_exporter.go +++ b/converter/internal/staticconvert/internal/build/snowflake_exporter.go @@ -1,25 +1,15 @@ package build import ( - "fmt" - "github.com/grafana/agent/component/discovery" "github.com/grafana/agent/component/prometheus/exporter/snowflake" - "github.com/grafana/agent/converter/internal/common" "github.com/grafana/agent/pkg/integrations/snowflake_exporter" "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsConfigBuilder) appendSnowflakeExporter(config *snowflake_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendSnowflakeExporter(config *snowflake_exporter.Config, instanceKey *string) discovery.Exports { args := toSnowflakeExporter(config) - compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) - b.f.Body().AppendBlock(common.NewBlockWithOverride( - []string{"prometheus", "exporter", "snowflake"}, - compLabel, - args, - )) - - return common.NewDiscoveryExports(fmt.Sprintf("prometheus.exporter.snowflake.%s.targets", compLabel)) + return b.appendExporterBlock(args, config.Name(), instanceKey, "snowflake") } func toSnowflakeExporter(config *snowflake_exporter.Config) *snowflake.Arguments { diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.river b/converter/internal/staticconvert/testdata-v2/integrations_v2.river index dbd3c58b3c74..3190bbb8f287 100644 --- a/converter/internal/staticconvert/testdata-v2/integrations_v2.river +++ b/converter/internal/staticconvert/testdata-v2/integrations_v2.river @@ -349,6 +349,19 @@ prometheus.scrape "integrations_redis" { job_name = "integrations/redis" } +prometheus.exporter.snowflake "integrations_snowflake" { + account_name = "XXXXXXX-YYYYYYY" + username = "snowflake-user" + password = "snowflake-pass" + warehouse = "SNOWFLAKE_WAREHOUSE" +} + +prometheus.scrape "integrations_snowflake" { + targets = prometheus.exporter.snowflake.integrations_snowflake.targets + forward_to = [prometheus.remote_write.metrics_default.receiver] + job_name = "integrations/snowflake" +} + prometheus.exporter.agent "integrations_agent" { } discovery.relabel "integrations_agent" { diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml b/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml index 49e8c378d15f..ad0880faeded 100644 --- a/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml +++ b/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml @@ -190,4 +190,10 @@ integrations: address: 192.168.1.3 module: mikrotik walk_params: private - auth: private \ No newline at end of file + auth: private + snowflake_configs: + - account_name: XXXXXXX-YYYYYYY + username: snowflake-user + password: snowflake-pass + warehouse: SNOWFLAKE_WAREHOUSE + role: ACCOUNTADMIN \ No newline at end of file diff --git a/converter/internal/staticconvert/validate.go b/converter/internal/staticconvert/validate.go index 59bffabff517..408e04610528 100644 --- a/converter/internal/staticconvert/validate.go +++ b/converter/internal/staticconvert/validate.go @@ -188,6 +188,7 @@ func validateIntegrationsV2(integrationsConfig *v2.SubsystemOptions) diag.Diagno case *postgres_exporter.Config: case *process_exporter.Config: case *redis_exporter.Config: + case *snowflake_exporter.Config: default: diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s integration.", v1_itg.Name())) }