diff --git a/cmd/internal/flowmode/cmd_convert.go b/cmd/internal/flowmode/cmd_convert.go index cba9bb49b92e..be25696d9ccb 100644 --- a/cmd/internal/flowmode/cmd_convert.go +++ b/cmd/internal/flowmode/cmd_convert.go @@ -112,7 +112,7 @@ func convert(r io.Reader, fc *flowConvert) error { return err } - riverBytes, diags := converter.Convert(inputBytes, converter.Input(fc.sourceFormat)) + riverBytes, diags := converter.Convert(inputBytes, converter.Input(fc.sourceFormat), []string{}) err = generateConvertReport(diags, fc) if err != nil { return err diff --git a/cmd/internal/flowmode/cmd_run.go b/cmd/internal/flowmode/cmd_run.go index 14a4ea112e84..f73fb09d2ee0 100644 --- a/cmd/internal/flowmode/cmd_run.go +++ b/cmd/internal/flowmode/cmd_run.go @@ -403,7 +403,7 @@ func loadFlowSource(path string, converterSourceFormat string, converterBypassEr } if converterSourceFormat != "flow" { var diags convert_diag.Diagnostics - bb, diags = converter.Convert(bb, converter.Input(converterSourceFormat)) + bb, diags = converter.Convert(bb, converter.Input(converterSourceFormat), []string{}) hasError := hasErrorLevel(diags, convert_diag.SeverityLevelError) hasCritical := hasErrorLevel(diags, convert_diag.SeverityLevelCritical) if hasCritical || (!converterBypassErrors && hasError) { diff --git a/converter/converter.go b/converter/converter.go index 1bf5857a5d3c..c5584950aff2 100644 --- a/converter/converter.go +++ b/converter/converter.go @@ -32,6 +32,10 @@ var SupportedFormats = []string{ // Convert generates a Grafana Agent Flow config given an input configuration // file. // +// extraArgs are supported to be passed along to a converter such as enabling +// integrations-next for the static converter. Converters that do not support +// extraArgs will return a critical severity diagnostic if any are passed. +// // Conversions are made as literally as possible, so the resulting config files // may be unoptimized (i.e., lacking component reuse). A converted config file // should just be the starting point rather than the final destination. @@ -41,14 +45,14 @@ var SupportedFormats = []string{ // because of mismatched functionality, an error is returned with no resulting // config. If the conversion completed successfully but generated warnings, an // error is returned alongside the resulting config. -func Convert(in []byte, kind Input) ([]byte, diag.Diagnostics) { +func Convert(in []byte, kind Input, extraArgs []string) ([]byte, diag.Diagnostics) { switch kind { case InputPrometheus: - return prometheusconvert.Convert(in) + return prometheusconvert.Convert(in, extraArgs) case InputPromtail: - return promtailconvert.Convert(in) + return promtailconvert.Convert(in, extraArgs) case InputStatic: - return staticconvert.Convert(in) + return staticconvert.Convert(in, extraArgs) } var diags diag.Diagnostics diff --git a/converter/internal/prometheusconvert/prometheusconvert.go b/converter/internal/prometheusconvert/prometheusconvert.go index ef58f34d5168..7c8108230192 100644 --- a/converter/internal/prometheusconvert/prometheusconvert.go +++ b/converter/internal/prometheusconvert/prometheusconvert.go @@ -20,9 +20,17 @@ import ( ) // Convert implements a Prometheus config converter. -func Convert(in []byte) ([]byte, diag.Diagnostics) { +// +// extraArgs are supported to mirror the other converter params due to shared +// testing code but they should be passed empty to this converter. +func Convert(in []byte, extraArgs []string) ([]byte, diag.Diagnostics) { var diags diag.Diagnostics + if len(extraArgs) > 0 { + diags.Add(diag.SeverityLevelCritical, fmt.Sprintf("extra arguments are not supported for the prometheus converter: %s", extraArgs)) + return nil, diags + } + promConfig, err := prom_config.Load(string(in), false, log.NewNopLogger()) if err != nil { diags.Add(diag.SeverityLevelCritical, fmt.Sprintf("failed to parse Prometheus config: %s", err)) diff --git a/converter/internal/prometheusconvert/prometheusconvert_test.go b/converter/internal/prometheusconvert/prometheusconvert_test.go index bded9ce3069c..00adf0544b81 100644 --- a/converter/internal/prometheusconvert/prometheusconvert_test.go +++ b/converter/internal/prometheusconvert/prometheusconvert_test.go @@ -9,5 +9,5 @@ import ( ) func TestConvert(t *testing.T) { - test_common.TestDirectory(t, "testdata", ".yaml", true, prometheusconvert.Convert) + test_common.TestDirectory(t, "testdata", ".yaml", true, []string{}, prometheusconvert.Convert) } diff --git a/converter/internal/promtailconvert/promtailconvert.go b/converter/internal/promtailconvert/promtailconvert.go index 05916fb7d019..21e1be683217 100644 --- a/converter/internal/promtailconvert/promtailconvert.go +++ b/converter/internal/promtailconvert/promtailconvert.go @@ -33,12 +33,20 @@ func (c *Config) Clone() flagext.Registerer { } // Convert implements a Promtail config converter. -func Convert(in []byte) ([]byte, diag.Diagnostics) { +// +// extraArgs are supported to mirror the other converter params due to shared +// testing code but they should be passed empty to this converter. +func Convert(in []byte, extraArgs []string) ([]byte, diag.Diagnostics) { var ( diags diag.Diagnostics cfg Config ) + if len(extraArgs) > 0 { + diags.Add(diag.SeverityLevelCritical, fmt.Sprintf("extra arguments are not supported for the promtail converter: %s", extraArgs)) + return nil, diags + } + // Set default values first. flagSet := flag.NewFlagSet("", flag.PanicOnError) err := lokicfgutil.Unmarshal(&cfg, diff --git a/converter/internal/promtailconvert/promtailconvert_test.go b/converter/internal/promtailconvert/promtailconvert_test.go index 2ebeb3c1ada0..02184f1fcf26 100644 --- a/converter/internal/promtailconvert/promtailconvert_test.go +++ b/converter/internal/promtailconvert/promtailconvert_test.go @@ -9,5 +9,5 @@ import ( ) func TestConvert(t *testing.T) { - test_common.TestDirectory(t, "testdata", ".yaml", true, promtailconvert.Convert) + test_common.TestDirectory(t, "testdata", ".yaml", true, []string{}, promtailconvert.Convert) } diff --git a/converter/internal/staticconvert/internal/build/agent_exporter.go b/converter/internal/staticconvert/internal/build/agent_exporter.go index 019bcd02cee9..2e7af7437192 100644 --- a/converter/internal/staticconvert/internal/build/agent_exporter.go +++ b/converter/internal/staticconvert/internal/build/agent_exporter.go @@ -9,7 +9,7 @@ import ( agent_exporter "github.com/grafana/agent/pkg/integrations/agent" ) -func (b *IntegrationsV1ConfigBuilder) appendAgentExporter(config *agent_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendAgentExporter(config *agent_exporter.Config) discovery.Exports { args := toAgentExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/apache_exporter.go b/converter/internal/staticconvert/internal/build/apache_exporter.go index ec064c10422e..0d3b1865b04f 100644 --- a/converter/internal/staticconvert/internal/build/apache_exporter.go +++ b/converter/internal/staticconvert/internal/build/apache_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/apache_http" ) -func (b *IntegrationsV1ConfigBuilder) appendApacheExporter(config *apache_http.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendApacheExporter(config *apache_http.Config) discovery.Exports { args := toApacheExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/azure_exporter.go b/converter/internal/staticconvert/internal/build/azure_exporter.go index 2f55f5ff1b4e..0a096901cef8 100644 --- a/converter/internal/staticconvert/internal/build/azure_exporter.go +++ b/converter/internal/staticconvert/internal/build/azure_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/azure_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendAzureExporter(config *azure_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendAzureExporter(config *azure_exporter.Config) discovery.Exports { args := toAzureExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/blackbox_exporter.go b/converter/internal/staticconvert/internal/build/blackbox_exporter.go index 5916ece64a28..5ab772e8ee60 100644 --- a/converter/internal/staticconvert/internal/build/blackbox_exporter.go +++ b/converter/internal/staticconvert/internal/build/blackbox_exporter.go @@ -11,7 +11,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendBlackboxExporter(config *blackbox_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendBlackboxExporter(config *blackbox_exporter.Config) discovery.Exports { args := toBlackboxExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/builder.go b/converter/internal/staticconvert/internal/build/builder.go index 74b20784ff8d..8c56d675a8d4 100644 --- a/converter/internal/staticconvert/internal/build/builder.go +++ b/converter/internal/staticconvert/internal/build/builder.go @@ -40,15 +40,15 @@ import ( prom_config "github.com/prometheus/prometheus/config" ) -type IntegrationsV1ConfigBuilder struct { +type IntegrationsConfigBuilder struct { f *builder.File diags *diag.Diagnostics cfg *config.Config globalCtx *GlobalContext } -func NewIntegrationsV1ConfigBuilder(f *builder.File, diags *diag.Diagnostics, cfg *config.Config, globalCtx *GlobalContext) *IntegrationsV1ConfigBuilder { - return &IntegrationsV1ConfigBuilder{ +func NewIntegrationsConfigBuilder(f *builder.File, diags *diag.Diagnostics, cfg *config.Config, globalCtx *GlobalContext) *IntegrationsConfigBuilder { + return &IntegrationsConfigBuilder{ f: f, diags: diags, cfg: cfg, @@ -56,13 +56,24 @@ func NewIntegrationsV1ConfigBuilder(f *builder.File, diags *diag.Diagnostics, cf } } -func (b *IntegrationsV1ConfigBuilder) Build() { +func (b *IntegrationsConfigBuilder) Build() { b.appendLogging(b.cfg.Server) b.appendServer(b.cfg.Server) b.appendIntegrations() } -func (b *IntegrationsV1ConfigBuilder) appendIntegrations() { +func (b *IntegrationsConfigBuilder) appendIntegrations() { + switch b.cfg.Integrations.Version { + case config.IntegrationsVersion1: + b.appendV1Integrations() + case config.IntegrationsVersion2: + b.appendV2Integrations() + default: + panic(fmt.Sprintf("unknown integrations version %d", b.cfg.Integrations.Version)) + } +} + +func (b *IntegrationsConfigBuilder) appendV1Integrations() { for _, integration := range b.cfg.Integrations.ConfigV1.Integrations { if !integration.Common.Enabled { continue @@ -140,7 +151,11 @@ func (b *IntegrationsV1ConfigBuilder) appendIntegrations() { } } -func (b *IntegrationsV1ConfigBuilder) appendExporter(commonConfig *int_config.Common, name string, extraTargets []discovery.Target) { +func (b *IntegrationsConfigBuilder) appendV2Integrations() { + +} + +func (b *IntegrationsConfigBuilder) appendExporter(commonConfig *int_config.Common, name string, extraTargets []discovery.Target) { scrapeConfig := prom_config.DefaultScrapeConfig scrapeConfig.JobName = fmt.Sprintf("integrations/%s", name) scrapeConfig.RelabelConfigs = commonConfig.RelabelConfigs diff --git a/converter/internal/staticconvert/internal/build/cadvisor_exporter.go b/converter/internal/staticconvert/internal/build/cadvisor_exporter.go index 5e21550142c9..04d414c14cd0 100644 --- a/converter/internal/staticconvert/internal/build/cadvisor_exporter.go +++ b/converter/internal/staticconvert/internal/build/cadvisor_exporter.go @@ -10,7 +10,7 @@ import ( cadvisor_integration "github.com/grafana/agent/pkg/integrations/cadvisor" ) -func (b *IntegrationsV1ConfigBuilder) appendCadvisorExporter(config *cadvisor_integration.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendCadvisorExporter(config *cadvisor_integration.Config) discovery.Exports { args := toCadvisorExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/cloudwatch_exporter.go b/converter/internal/staticconvert/internal/build/cloudwatch_exporter.go index c84a7fd00395..2afdd0170756 100644 --- a/converter/internal/staticconvert/internal/build/cloudwatch_exporter.go +++ b/converter/internal/staticconvert/internal/build/cloudwatch_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/cloudwatch_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendCloudwatchExporter(config *cloudwatch_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendCloudwatchExporter(config *cloudwatch_exporter.Config) discovery.Exports { args := toCloudwatchExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/consul_exporter.go b/converter/internal/staticconvert/internal/build/consul_exporter.go index 32a4c6736e5f..3b6ba2f74018 100644 --- a/converter/internal/staticconvert/internal/build/consul_exporter.go +++ b/converter/internal/staticconvert/internal/build/consul_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/consul_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendConsulExporter(config *consul_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendConsulExporter(config *consul_exporter.Config) discovery.Exports { args := toConsulExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/dnsmasq_exporter.go b/converter/internal/staticconvert/internal/build/dnsmasq_exporter.go index 230e59e22827..df46fe453987 100644 --- a/converter/internal/staticconvert/internal/build/dnsmasq_exporter.go +++ b/converter/internal/staticconvert/internal/build/dnsmasq_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/dnsmasq_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendDnsmasqExporter(config *dnsmasq_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendDnsmasqExporter(config *dnsmasq_exporter.Config) discovery.Exports { args := toDnsmasqExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/elasticsearch_exporter.go b/converter/internal/staticconvert/internal/build/elasticsearch_exporter.go index 82d17e05b6f0..6d874048dba2 100644 --- a/converter/internal/staticconvert/internal/build/elasticsearch_exporter.go +++ b/converter/internal/staticconvert/internal/build/elasticsearch_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/elasticsearch_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendElasticsearchExporter(config *elasticsearch_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendElasticsearchExporter(config *elasticsearch_exporter.Config) discovery.Exports { args := toElasticsearchExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/gcp_exporter.go b/converter/internal/staticconvert/internal/build/gcp_exporter.go index 24d194921c93..954b67943210 100644 --- a/converter/internal/staticconvert/internal/build/gcp_exporter.go +++ b/converter/internal/staticconvert/internal/build/gcp_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/gcp_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendGcpExporter(config *gcp_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendGcpExporter(config *gcp_exporter.Config) discovery.Exports { args := toGcpExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/github_exporter.go b/converter/internal/staticconvert/internal/build/github_exporter.go index 9e4e3cd79e9a..d2b228de38a0 100644 --- a/converter/internal/staticconvert/internal/build/github_exporter.go +++ b/converter/internal/staticconvert/internal/build/github_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendGithubExporter(config *github_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendGithubExporter(config *github_exporter.Config) discovery.Exports { args := toGithubExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/kafka_exporter.go b/converter/internal/staticconvert/internal/build/kafka_exporter.go index fbcfcc0b05ab..cf47bba409ff 100644 --- a/converter/internal/staticconvert/internal/build/kafka_exporter.go +++ b/converter/internal/staticconvert/internal/build/kafka_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/kafka_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendKafkaExporter(config *kafka_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendKafkaExporter(config *kafka_exporter.Config) discovery.Exports { args := toKafkaExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/logging.go b/converter/internal/staticconvert/internal/build/logging.go index 17e1f0f61446..24c4d9ba40db 100644 --- a/converter/internal/staticconvert/internal/build/logging.go +++ b/converter/internal/staticconvert/internal/build/logging.go @@ -8,7 +8,7 @@ import ( "github.com/grafana/agent/pkg/server" ) -func (b *IntegrationsV1ConfigBuilder) appendLogging(config *server.Config) { +func (b *IntegrationsConfigBuilder) appendLogging(config *server.Config) { args := toLogging(config) if !reflect.DeepEqual(*args, logging.DefaultOptions) { b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/memcached_exporter.go b/converter/internal/staticconvert/internal/build/memcached_exporter.go index c01622bbb3c2..a9f179c04b4a 100644 --- a/converter/internal/staticconvert/internal/build/memcached_exporter.go +++ b/converter/internal/staticconvert/internal/build/memcached_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/memcached_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendMemcachedExporter(config *memcached_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendMemcachedExporter(config *memcached_exporter.Config) discovery.Exports { args := toMemcachedExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/mongodb_exporter.go b/converter/internal/staticconvert/internal/build/mongodb_exporter.go index efae1b043898..88b2e075be92 100644 --- a/converter/internal/staticconvert/internal/build/mongodb_exporter.go +++ b/converter/internal/staticconvert/internal/build/mongodb_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendMongodbExporter(config *mongodb_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendMongodbExporter(config *mongodb_exporter.Config) discovery.Exports { args := toMongodbExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/mssql_exporter.go b/converter/internal/staticconvert/internal/build/mssql_exporter.go index 5d1dd142d366..8615d6c74182 100644 --- a/converter/internal/staticconvert/internal/build/mssql_exporter.go +++ b/converter/internal/staticconvert/internal/build/mssql_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendMssqlExporter(config *mssql_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendMssqlExporter(config *mssql_exporter.Config) discovery.Exports { args := toMssqlExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/mysqld_exporter.go b/converter/internal/staticconvert/internal/build/mysqld_exporter.go index 0f821fa10f68..52d6670be9dd 100644 --- a/converter/internal/staticconvert/internal/build/mysqld_exporter.go +++ b/converter/internal/staticconvert/internal/build/mysqld_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendMysqldExporter(config *mysqld_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendMysqldExporter(config *mysqld_exporter.Config) discovery.Exports { args := toMysqldExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/node_exporter.go b/converter/internal/staticconvert/internal/build/node_exporter.go index 13462edd40ff..9fad26b460ff 100644 --- a/converter/internal/staticconvert/internal/build/node_exporter.go +++ b/converter/internal/staticconvert/internal/build/node_exporter.go @@ -7,7 +7,7 @@ import ( "github.com/grafana/agent/pkg/integrations/node_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendNodeExporter(config *node_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendNodeExporter(config *node_exporter.Config) discovery.Exports { args := toNodeExporter(config) b.f.Body().AppendBlock(common.NewBlockWithOverride( []string{"prometheus", "exporter", "unix"}, diff --git a/converter/internal/staticconvert/internal/build/oracledb_exporter.go b/converter/internal/staticconvert/internal/build/oracledb_exporter.go index d8edb0bf0a40..e1ad64c2404a 100644 --- a/converter/internal/staticconvert/internal/build/oracledb_exporter.go +++ b/converter/internal/staticconvert/internal/build/oracledb_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendOracledbExporter(config *oracledb_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendOracledbExporter(config *oracledb_exporter.Config) discovery.Exports { args := toOracledbExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/postgres_exporter.go b/converter/internal/staticconvert/internal/build/postgres_exporter.go index c87343933f6f..863999bdadb8 100644 --- a/converter/internal/staticconvert/internal/build/postgres_exporter.go +++ b/converter/internal/staticconvert/internal/build/postgres_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendPostgresExporter(config *postgres_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendPostgresExporter(config *postgres_exporter.Config) discovery.Exports { args := toPostgresExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/process_exporter.go b/converter/internal/staticconvert/internal/build/process_exporter.go index 104d85fcfac4..2172865c2c0c 100644 --- a/converter/internal/staticconvert/internal/build/process_exporter.go +++ b/converter/internal/staticconvert/internal/build/process_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/process_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendProcessExporter(config *process_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendProcessExporter(config *process_exporter.Config) discovery.Exports { args := toProcessExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/redis_exporter.go b/converter/internal/staticconvert/internal/build/redis_exporter.go index 3c03b4171418..dc87a0293723 100644 --- a/converter/internal/staticconvert/internal/build/redis_exporter.go +++ b/converter/internal/staticconvert/internal/build/redis_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendRedisExporter(config *redis_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendRedisExporter(config *redis_exporter.Config) discovery.Exports { args := toRedisExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/server.go b/converter/internal/staticconvert/internal/build/server.go index 3617c5dcc14d..0204101ae2af 100644 --- a/converter/internal/staticconvert/internal/build/server.go +++ b/converter/internal/staticconvert/internal/build/server.go @@ -8,7 +8,7 @@ import ( "github.com/grafana/agent/service/http" ) -func (b *IntegrationsV1ConfigBuilder) appendServer(config *server.Config) { +func (b *IntegrationsConfigBuilder) appendServer(config *server.Config) { args := toServer(config) if !reflect.DeepEqual(*args.TLS, http.TLSArguments{}) { b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/snmp_exporter.go b/converter/internal/staticconvert/internal/build/snmp_exporter.go index a0df3bb3c109..6d03c27cce69 100644 --- a/converter/internal/staticconvert/internal/build/snmp_exporter.go +++ b/converter/internal/staticconvert/internal/build/snmp_exporter.go @@ -11,7 +11,7 @@ import ( snmp_config "github.com/prometheus/snmp_exporter/config" ) -func (b *IntegrationsV1ConfigBuilder) appendSnmpExporter(config *snmp_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendSnmpExporter(config *snmp_exporter.Config) discovery.Exports { args := toSnmpExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/snowflake_exporter.go b/converter/internal/staticconvert/internal/build/snowflake_exporter.go index 6ca50c1f01f8..34f605564c35 100644 --- a/converter/internal/staticconvert/internal/build/snowflake_exporter.go +++ b/converter/internal/staticconvert/internal/build/snowflake_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendSnowflakeExporter(config *snowflake_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendSnowflakeExporter(config *snowflake_exporter.Config) discovery.Exports { args := toSnowflakeExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/squid_exporter.go b/converter/internal/staticconvert/internal/build/squid_exporter.go index 48a5682ff699..c275b0dd04a6 100644 --- a/converter/internal/staticconvert/internal/build/squid_exporter.go +++ b/converter/internal/staticconvert/internal/build/squid_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/river/rivertypes" ) -func (b *IntegrationsV1ConfigBuilder) appendSquidExporter(config *squid_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendSquidExporter(config *squid_exporter.Config) discovery.Exports { args := toSquidExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/statsd_exporter.go b/converter/internal/staticconvert/internal/build/statsd_exporter.go index 784aca4d54df..719ce2baf73b 100644 --- a/converter/internal/staticconvert/internal/build/statsd_exporter.go +++ b/converter/internal/staticconvert/internal/build/statsd_exporter.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/agent/pkg/integrations/statsd_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendStatsdExporter(config *statsd_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendStatsdExporter(config *statsd_exporter.Config) discovery.Exports { args := toStatsdExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/internal/build/windows_exporter.go b/converter/internal/staticconvert/internal/build/windows_exporter.go index 335dfd25ad47..bfd9fb771155 100644 --- a/converter/internal/staticconvert/internal/build/windows_exporter.go +++ b/converter/internal/staticconvert/internal/build/windows_exporter.go @@ -9,7 +9,7 @@ import ( "github.com/grafana/agent/pkg/integrations/windows_exporter" ) -func (b *IntegrationsV1ConfigBuilder) appendWindowsExporter(config *windows_exporter.Config) discovery.Exports { +func (b *IntegrationsConfigBuilder) appendWindowsExporter(config *windows_exporter.Config) discovery.Exports { args := toWindowsExporter(config) compLabel := common.LabelForParts(b.globalCtx.LabelPrefix, config.Name()) b.f.Body().AppendBlock(common.NewBlockWithOverride( diff --git a/converter/internal/staticconvert/staticconvert.go b/converter/internal/staticconvert/staticconvert.go index fd4c1df90340..a84a222317a4 100644 --- a/converter/internal/staticconvert/staticconvert.go +++ b/converter/internal/staticconvert/staticconvert.go @@ -24,11 +24,20 @@ import ( ) // Convert implements a Static config converter. -func Convert(in []byte) ([]byte, diag.Diagnostics) { +// +// extraArgs are supported to be passed along to the Static config parser such +// as enabling integrations-next. +func Convert(in []byte, extraArgs []string) ([]byte, diag.Diagnostics) { var diags diag.Diagnostics - - fs := flag.NewFlagSet("convert", flag.ExitOnError) - staticConfig, err := config.LoadFromFunc(fs, []string{"-config.file", "convert", "-config.expand-env"}, func(_, _ string, expandEnvVars bool, c *config.Config) error { + // diags := validateExtraArgs(extraArgs) + // if len(diags) > 0 { + // return nil, diags + // } + + fs := flag.NewFlagSet("convert", flag.ContinueOnError) + args := []string{"-config.file", "convert", "-config.expand-env"} + args = append(args, extraArgs...) + staticConfig, err := config.LoadFromFunc(fs, args, func(_, _ string, expandEnvVars bool, c *config.Config) error { return config.LoadBytes(in, expandEnvVars, c) }) @@ -65,8 +74,7 @@ func AppendAll(f *builder.File, staticConfig *config.Config) diag.Diagnostics { diags.AddAll(appendStaticPrometheus(f, staticConfig)) diags.AddAll(appendStaticPromtail(f, staticConfig)) - diags.AddAll(appendStaticIntegrationsV1(f, staticConfig)) - // TODO integrations v2 + diags.AddAll(appendStaticIntegrations(f, staticConfig)) // TODO otel diags.AddAll(validate(staticConfig)) @@ -160,10 +168,10 @@ func appendStaticPromtail(f *builder.File, staticConfig *config.Config) diag.Dia return diags } -func appendStaticIntegrationsV1(f *builder.File, staticConfig *config.Config) diag.Diagnostics { +func appendStaticIntegrations(f *builder.File, staticConfig *config.Config) diag.Diagnostics { var diags diag.Diagnostics - b := build.NewIntegrationsV1ConfigBuilder(f, &diags, staticConfig, &build.GlobalContext{LabelPrefix: "integrations"}) + b := build.NewIntegrationsConfigBuilder(f, &diags, staticConfig, &build.GlobalContext{LabelPrefix: "integrations"}) b.Build() return diags diff --git a/converter/internal/staticconvert/staticconvert_test.go b/converter/internal/staticconvert/staticconvert_test.go index d5d16bfd55a6..d283164e4453 100644 --- a/converter/internal/staticconvert/staticconvert_test.go +++ b/converter/internal/staticconvert/staticconvert_test.go @@ -10,9 +10,10 @@ import ( ) func TestConvert(t *testing.T) { - test_common.TestDirectory(t, "testdata", ".yaml", true, staticconvert.Convert) + test_common.TestDirectory(t, "testdata", ".yaml", true, []string{}, staticconvert.Convert) + test_common.TestDirectory(t, "testdata-v2", ".yaml", true, []string{"-enable-features", "integrations-next"}, staticconvert.Convert) if runtime.GOOS == "windows" { - test_common.TestDirectory(t, "testdata_windows", ".yaml", true, staticconvert.Convert) + test_common.TestDirectory(t, "testdata_windows", ".yaml", true, []string{}, staticconvert.Convert) } } diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.diags b/converter/internal/staticconvert/testdata-v2/integrations_v2.diags new file mode 100644 index 000000000000..a4a05d1a3b58 --- /dev/null +++ b/converter/internal/staticconvert/testdata-v2/integrations_v2.diags @@ -0,0 +1 @@ +(Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. \ No newline at end of file diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.river b/converter/internal/staticconvert/testdata-v2/integrations_v2.river new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml b/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml new file mode 100644 index 000000000000..a3127dcad5db --- /dev/null +++ b/converter/internal/staticconvert/testdata-v2/integrations_v2.yaml @@ -0,0 +1,8 @@ +metrics: + global: + remote_write: + - url: http://localhost:9009/api/prom/push + +integrations: + agent: + instance: "agent" \ No newline at end of file diff --git a/converter/internal/staticconvert/validate.go b/converter/internal/staticconvert/validate.go index 2e9623dbca25..a34bac819bb1 100644 --- a/converter/internal/staticconvert/validate.go +++ b/converter/internal/staticconvert/validate.go @@ -6,6 +6,7 @@ import ( "github.com/grafana/agent/converter/diag" "github.com/grafana/agent/converter/internal/common" "github.com/grafana/agent/pkg/config" + v1 "github.com/grafana/agent/pkg/integrations" agent_exporter "github.com/grafana/agent/pkg/integrations/agent" "github.com/grafana/agent/pkg/integrations/apache_http" "github.com/grafana/agent/pkg/integrations/azure_exporter" @@ -31,6 +32,7 @@ import ( "github.com/grafana/agent/pkg/integrations/snowflake_exporter" "github.com/grafana/agent/pkg/integrations/squid_exporter" "github.com/grafana/agent/pkg/integrations/statsd_exporter" + v2 "github.com/grafana/agent/pkg/integrations/v2" "github.com/grafana/agent/pkg/integrations/windows_exporter" "github.com/grafana/agent/pkg/logs" "github.com/grafana/agent/pkg/metrics" @@ -98,9 +100,20 @@ func validateMetrics(metricsConfig metrics.Config, grpcListenPort int) diag.Diag } func validateIntegrations(integrationsConfig config.VersionedIntegrations) diag.Diagnostics { + switch integrationsConfig.Version { + case config.IntegrationsVersion1: + return validateIntegrationsV1(integrationsConfig.ConfigV1) + case config.IntegrationsVersion2: + return validateIntegrationsV2(integrationsConfig.ConfigV2) + default: + panic(fmt.Sprintf("unknown integrations version %d", integrationsConfig.Version)) + } +} + +func validateIntegrationsV1(integrationsConfig *v1.ManagerConfig) diag.Diagnostics { var diags diag.Diagnostics - for _, integration := range integrationsConfig.ConfigV1.Integrations { + for _, integration := range integrationsConfig.Integrations { if !integration.Common.Enabled { diags.Add(diag.SeverityLevelWarn, fmt.Sprintf("disabled integrations do nothing and are not included in the output: %s.", integration.Name())) continue @@ -141,6 +154,14 @@ func validateIntegrations(integrationsConfig config.VersionedIntegrations) diag. return diags } +func validateIntegrationsV2(integrationsConfig *v2.SubsystemOptions) diag.Diagnostics { + var diags diag.Diagnostics + + // TODO + + return diags +} + func validateTraces(tracesConfig traces.Config) diag.Diagnostics { var diags diag.Diagnostics diff --git a/converter/internal/test_common/testing.go b/converter/internal/test_common/testing.go index 1cbbf485e7f6..4ee3f2f23be3 100644 --- a/converter/internal/test_common/testing.go +++ b/converter/internal/test_common/testing.go @@ -39,7 +39,7 @@ const ( // 4. If the current filename.sourceSuffix has a matching filename.river, read // the contents of filename.river and validate that they match the river // configuration generated by calling convert in step 1. -func TestDirectory(t *testing.T, folderPath string, sourceSuffix string, loadFlowConfig bool, convert func(in []byte) ([]byte, diag.Diagnostics)) { +func TestDirectory(t *testing.T, folderPath string, sourceSuffix string, loadFlowConfig bool, extraArgs []string, convert func(in []byte, extraArgs []string) ([]byte, diag.Diagnostics)) { require.NoError(t, filepath.WalkDir(folderPath, func(path string, d fs.DirEntry, _ error) error { if d.IsDir() { return nil @@ -54,7 +54,7 @@ func TestDirectory(t *testing.T, folderPath string, sourceSuffix string, loadFlo t.Fatalf("no expected diags or river for %s - missing test expectations?", path) } - actualRiver, actualDiags := convert(getSourceContents(t, path)) + actualRiver, actualDiags := convert(getSourceContents(t, path), extraArgs) // Skip Info level diags for this testing. These would create // a lot of unnecessary noise. diff --git a/pkg/config/agentmanagement_remote_config.go b/pkg/config/agentmanagement_remote_config.go index 257c410c105e..d40b70551da1 100644 --- a/pkg/config/agentmanagement_remote_config.go +++ b/pkg/config/agentmanagement_remote_config.go @@ -55,7 +55,7 @@ func (rc *RemoteConfig) BuildAgentConfig() (*Config, error) { } // For now Agent Management only supports integrations v1 - if err := c.Integrations.setVersion(integrationsVersion1); err != nil { + if err := c.Integrations.setVersion(IntegrationsVersion1); err != nil { return nil, err } diff --git a/pkg/config/config.go b/pkg/config/config.go index 21b9ffe1422a..5aa6d6200254 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -419,9 +419,9 @@ func applyIntegrationValuesFromFlagset(fs *flag.FlagSet, args []string, path str // Complete unmarshaling integrations using the version from the flag. This // MUST be called before ApplyDefaults. - version := integrationsVersion1 + version := IntegrationsVersion1 if features.Enabled(fs, featIntegrationsNext) { - version = integrationsVersion2 + version = IntegrationsVersion2 } if err := cfg.Integrations.setVersion(version); err != nil { @@ -504,7 +504,7 @@ func CheckSecret(t *testing.T, rawCfg string, originalValue string) { // Set integrations version to make sure our marshal function goes through // the custom marshaling code. - err = cfg.Integrations.setVersion(integrationsVersion1) + err = cfg.Integrations.setVersion(IntegrationsVersion1) require.NoError(t, err) bb, err := yaml.Marshal(&cfg) diff --git a/pkg/config/integrations.go b/pkg/config/integrations.go index acf76492aff3..2edd0d75aba8 100644 --- a/pkg/config/integrations.go +++ b/pkg/config/integrations.go @@ -16,18 +16,18 @@ import ( "gopkg.in/yaml.v2" ) -type integrationsVersion int +type IntegrationsVersion int const ( - integrationsVersion1 integrationsVersion = iota - integrationsVersion2 + IntegrationsVersion1 IntegrationsVersion = iota + IntegrationsVersion2 ) // DefaultVersionedIntegrations is the default config for integrations. func DefaultVersionedIntegrations() VersionedIntegrations { configV1 := v1.DefaultManagerConfig() return VersionedIntegrations{ - version: integrationsVersion1, + Version: IntegrationsVersion1, ConfigV1: &configV1, } } @@ -35,11 +35,11 @@ func DefaultVersionedIntegrations() VersionedIntegrations { // VersionedIntegrations abstracts the subsystem configs for integrations v1 // and v2. VersionedIntegrations can only be unmarshaled as part of Load. type VersionedIntegrations struct { - version integrationsVersion + Version IntegrationsVersion raw util.RawYAML ConfigV1 *v1.ManagerConfig - configV2 *v2.SubsystemOptions + ConfigV2 *v2.SubsystemOptions // ExtraIntegrations is used when adding any integrations NOT in the default agent configuration ExtraIntegrations []v2.Config @@ -54,7 +54,7 @@ var ( // setVersion is invoked. func (c *VersionedIntegrations) UnmarshalYAML(unmarshal func(interface{}) error) error { c.ConfigV1 = nil - c.configV2 = nil + c.ConfigV2 = nil return unmarshal(&c.raw) } @@ -63,8 +63,8 @@ func (c VersionedIntegrations) MarshalYAML() (interface{}, error) { switch { case c.ConfigV1 != nil: return c.ConfigV1, nil - case c.configV2 != nil: - return c.configV2, nil + case c.ConfigV2 != nil: + return c.ConfigV2, nil default: // A pointer is needed for the yaml.Marshaler implementation to work. return &c.raw, nil @@ -76,8 +76,8 @@ func (c VersionedIntegrations) IsZero() bool { switch { case c.ConfigV1 != nil: return reflect.ValueOf(*c.ConfigV1).IsZero() - case c.configV2 != nil: - return reflect.ValueOf(*c.configV2).IsZero() + case c.ConfigV2 != nil: + return reflect.ValueOf(*c.ConfigV2).IsZero() default: return len(c.raw) == 0 } @@ -86,10 +86,10 @@ func (c VersionedIntegrations) IsZero() bool { // ApplyDefaults applies defaults to the subsystem based on globals. func (c *VersionedIntegrations) ApplyDefaults(sflags *server.Flags, mcfg *metrics.Config) error { switch { - case c.version != integrationsVersion2 && c.ConfigV1 != nil: + case c.Version != IntegrationsVersion2 && c.ConfigV1 != nil: return c.ConfigV1.ApplyDefaults(sflags, mcfg) - case c.configV2 != nil: - return c.configV2.ApplyDefaults(mcfg) + case c.ConfigV2 != nil: + return c.ConfigV2.ApplyDefaults(mcfg) default: // No-op return nil @@ -98,11 +98,11 @@ func (c *VersionedIntegrations) ApplyDefaults(sflags *server.Flags, mcfg *metric // setVersion completes the deferred unmarshal and unmarshals the raw YAML into // the subsystem config for version v. -func (c *VersionedIntegrations) setVersion(v integrationsVersion) error { - c.version = v +func (c *VersionedIntegrations) setVersion(v IntegrationsVersion) error { + c.Version = v - switch c.version { - case integrationsVersion1: + switch c.Version { + case IntegrationsVersion1: // Do not overwrite the config if it's already been set. This is relevant for // cases where the config has already been loaded via other means (example: Agent // Management snippets). @@ -113,20 +113,20 @@ func (c *VersionedIntegrations) setVersion(v integrationsVersion) error { cfg := v1.DefaultManagerConfig() c.ConfigV1 = &cfg return yaml.UnmarshalStrict(c.raw, c.ConfigV1) - case integrationsVersion2: + case IntegrationsVersion2: cfg := v2.DefaultSubsystemOptions // this is needed for dynamic configuration, the unmarshal doesn't work correctly if // this is not nil. c.ConfigV1 = nil - c.configV2 = &cfg - err := yaml.UnmarshalStrict(c.raw, c.configV2) + c.ConfigV2 = &cfg + err := yaml.UnmarshalStrict(c.raw, c.ConfigV2) if err != nil { return err } - c.configV2.Configs = append(c.configV2.Configs, c.ExtraIntegrations...) + c.ConfigV2.Configs = append(c.ConfigV2.Configs, c.ExtraIntegrations...) return nil default: - panic(fmt.Sprintf("unknown integrations version %d", c.version)) + panic(fmt.Sprintf("unknown integrations version %d", c.Version)) } } @@ -138,8 +138,8 @@ func (c *VersionedIntegrations) EnabledIntegrations() []string { integrations[integration.Name()] = struct{}{} } } - if c.configV2 != nil { - for _, integration := range c.configV2.Configs { + if c.ConfigV2 != nil { + for _, integration := range c.ConfigV2.Configs { integrations[integration.Name()] = struct{}{} } } @@ -160,7 +160,7 @@ type Integrations interface { // of useV2. globals.SubsystemOptions will be automatically set if cfg.Version // is set to IntegrationsVersion2. func NewIntegrations(logger log.Logger, cfg *VersionedIntegrations, globals IntegrationsGlobals) (Integrations, error) { - if cfg.version != integrationsVersion2 { + if cfg.Version != IntegrationsVersion2 { instance, err := v1.NewManager(*cfg.ConfigV1, logger, globals.Metrics.InstanceManager(), globals.Metrics.Validate) if err != nil { return nil, err @@ -170,7 +170,7 @@ func NewIntegrations(logger log.Logger, cfg *VersionedIntegrations, globals Inte level.Warn(logger).Log("msg", "integrations-next is enabled. integrations-next is subject to change") - globals.SubsystemOpts = *cfg.configV2 + globals.SubsystemOpts = *cfg.ConfigV2 instance, err := v2.NewSubsystem(logger, globals) if err != nil { return nil, err @@ -187,6 +187,6 @@ func (s *v1Integrations) ApplyConfig(cfg *VersionedIntegrations, _ IntegrationsG type v2Integrations struct{ *v2.Subsystem } func (s *v2Integrations) ApplyConfig(cfg *VersionedIntegrations, globals IntegrationsGlobals) error { - globals.SubsystemOpts = *cfg.configV2 + globals.SubsystemOpts = *cfg.ConfigV2 return s.Subsystem.ApplyConfig(globals) } diff --git a/pkg/config/integrations_test.go b/pkg/config/integrations_test.go index 9b03436fba87..a099951a3ab4 100644 --- a/pkg/config/integrations_test.go +++ b/pkg/config/integrations_test.go @@ -43,7 +43,7 @@ integrations: return LoadBytes([]byte(cfg), false, c) }) require.NoError(t, err) - require.NotNil(t, c.Integrations.configV2) + require.NotNil(t, c.Integrations.ConfigV2) } func TestEnabledIntegrations_v1(t *testing.T) { @@ -128,6 +128,6 @@ integrations: require.Equal(t, 1, len(c.Integrations.ConfigV1.Integrations)) c.Integrations.raw = util.RawYAML{} - c.Integrations.setVersion(integrationsVersion1) + c.Integrations.setVersion(IntegrationsVersion1) require.Equal(t, 1, len(c.Integrations.ConfigV1.Integrations)) }