Skip to content

Commit

Permalink
wire up snowflake exporter for 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 Nov 3, 2023
1 parent a6a819a commit a68baf3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
4 changes: 3 additions & 1 deletion converter/internal/staticconvert/internal/build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions converter/internal/staticconvert/testdata-v2/integrations_v2.river
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,10 @@ integrations:
address: 192.168.1.3
module: mikrotik
walk_params: private
auth: private
auth: private
snowflake_configs:
- account_name: XXXXXXX-YYYYYYY
username: snowflake-user
password: snowflake-pass
warehouse: SNOWFLAKE_WAREHOUSE
role: ACCOUNTADMIN
1 change: 1 addition & 0 deletions converter/internal/staticconvert/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down

0 comments on commit a68baf3

Please sign in to comment.