From 06c6792186357c8fb31a9e22c70a18e7b5cbd22a Mon Sep 17 00:00:00 2001 From: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:47:18 -0400 Subject: [PATCH] Clearer converter diagnostics (#5505) * Update a bunch of converter messages and use standardized functions where possible for validation. * default promtail log level from static converter so warnings don't show * update migration doc output to match current behaviour * refactor validation helper functions Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --------- Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --- CHANGELOG.md | 3 + converter/diag/diagnostics.go | 2 +- .../internal/common/http_client_config.go | 19 +-- converter/internal/common/validate.go | 46 ++++--- converter/internal/common/validate_test.go | 122 ++++++++++++++++++ .../component/digitalocean.go | 22 +--- .../prometheusconvert/component/docker.go | 10 +- .../prometheusconvert/component/ec2.go | 46 ++----- .../prometheusconvert/component/lightsail.go | 46 ++----- .../prometheusconvert/component/scrape.go | 5 +- .../component/service_discovery.go | 2 +- .../testdata/digitalocean.diags | 6 +- .../prometheusconvert/testdata/ec2.diags | 2 +- .../testdata/lightsail.diags | 2 +- .../testdata/unsupported.diags | 24 ++-- .../internal/prometheusconvert/validate.go | 48 ++----- .../promtailconvert/internal/build/stages.go | 2 +- .../promtailconvert/testdata/kubernetes.diags | 2 +- .../testdata/unsupported.diags | 3 +- .../internal/promtailconvert/validate.go | 6 +- .../staticconvert/internal/build/builder.go | 2 +- .../internal/staticconvert/staticconvert.go | 6 + .../staticconvert/testdata/prom_scrape.diags | 4 +- .../testdata/promtail_prom.diags | 4 - .../testdata/promtail_scrape.diags | 2 - .../staticconvert/testdata/sanitize.diags | 6 +- .../staticconvert/testdata/unsupported.diags | 16 +-- converter/internal/staticconvert/validate.go | 29 ++--- .../getting-started/migrating-from-static.md | 4 +- 29 files changed, 266 insertions(+), 225 deletions(-) create mode 100644 converter/internal/common/validate_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a8960d866c..39f33d3ee221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,9 @@ Main (unreleased) - Fixed issue where adding a module after initial start, that failed to load then subsequently resolving the issue would cause the module to permanently fail to load with `id already exists` error. (@mattdurham) +- Fixed some converter diagnostics so they show as warnings rather than errors. Improve + clarity for various diagnostics. (@erikbaranowski) + - Allow the usage of encodings other than UTF8 to be used with environment variable expansion. (@mattdurham) - Fixed an issue where native histogram time series were being dropped silently. (@krajorama) diff --git a/converter/diag/diagnostics.go b/converter/diag/diagnostics.go index cd5d06dd4f54..6c3fcfba45d8 100644 --- a/converter/diag/diagnostics.go +++ b/converter/diag/diagnostics.go @@ -51,7 +51,7 @@ func (ds Diagnostics) GenerateReport(writer io.Writer, reportType string) error case Text: return generateTextReport(writer, ds) default: - return fmt.Errorf("unsupported diagnostic report type %q", reportType) + return fmt.Errorf("Invalid diagnostic report type %q", reportType) } } diff --git a/converter/internal/common/http_client_config.go b/converter/internal/common/http_client_config.go index ce082f0c68bb..55b880903621 100644 --- a/converter/internal/common/http_client_config.go +++ b/converter/internal/common/http_client_config.go @@ -30,21 +30,10 @@ func ToHttpClientConfig(httpClientConfig *prom_config.HTTPClientConfig) *config. func ValidateHttpClientConfig(httpClientConfig *prom_config.HTTPClientConfig) diag.Diagnostics { var diags diag.Diagnostics - if httpClientConfig.NoProxy != "" { - diags.Add(diag.SeverityLevelError, "unsupported HTTP Client config no_proxy was provided") - } - - if httpClientConfig.ProxyFromEnvironment { - diags.Add(diag.SeverityLevelError, "unsupported HTTP Client config proxy_from_environment was provided") - } - - if len(httpClientConfig.ProxyConnectHeader) > 0 { - diags.Add(diag.SeverityLevelError, "unsupported HTTP Client config proxy_connect_header was provided") - } - - if httpClientConfig.TLSConfig.MaxVersion != 0 { - diags.Add(diag.SeverityLevelError, "unsupported HTTP Client config max_version was provided") - } + diags.AddAll(ValidateSupported(NotEquals, httpClientConfig.NoProxy, "", "HTTP Client no_proxy", "")) + diags.AddAll(ValidateSupported(Equals, httpClientConfig.ProxyFromEnvironment, true, "HTTP Client proxy_from_environment", "")) + diags.AddAll(ValidateSupported(Equals, len(httpClientConfig.ProxyConnectHeader) > 0, true, "HTTP Client proxy_connect_header", "")) + diags.AddAll(ValidateSupported(NotEquals, httpClientConfig.TLSConfig.MaxVersion, prom_config.TLSVersion(0), "HTTP Client max_version", "")) return diags } diff --git a/converter/internal/common/validate.go b/converter/internal/common/validate.go index ca514a668eca..87167822b040 100644 --- a/converter/internal/common/validate.go +++ b/converter/internal/common/validate.go @@ -9,32 +9,46 @@ import ( "github.com/grafana/river/token/builder" ) -func UnsupportedNotDeepEquals(a any, b any, name string) diag.Diagnostics { - return UnsupportedNotDeepEqualsMessage(a, b, name, "") -} +const ( + Equals = iota + NotEquals + DeepEquals + NotDeepEquals +) -func UnsupportedNotDeepEqualsMessage(a any, b any, name string, message string) diag.Diagnostics { +// ValidateSupported will return a diagnostic error if the validationType +// specified results in a match for value1 and value2. +// +// For example, if using validationType Equals and value1 is equal to value2, +// then a diagnostic error will be returned. +func ValidateSupported(validationType int, value1 any, value2 any, name string, message string) diag.Diagnostics { var diags diag.Diagnostics - if !reflect.DeepEqual(a, b) { + var isInvalid bool + + switch validationType { + case Equals: + isInvalid = value1 == value2 + case NotEquals: + isInvalid = value1 != value2 + case DeepEquals: + isInvalid = reflect.DeepEqual(value1, value2) + case NotDeepEquals: + isInvalid = !reflect.DeepEqual(value1, value2) + default: + diags.Add(diag.SeverityLevelCritical, fmt.Sprintf("Invalid converter validation type was requested: %d.", validationType)) + } + + if isInvalid { if message != "" { - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported %s config was provided: %s", name, message)) + diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s config: %s", name, message)) } else { - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported %s config was provided.", name)) + diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s config.", name)) } } return diags } -func UnsupportedNotEquals(a any, b any, name string) diag.Diagnostics { - var diags diag.Diagnostics - if a != b { - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported %s config was provided.", name)) - } - - return diags -} - // ValidateNodes will look at the final nodes and ensure that there are no // duplicate labels. func ValidateNodes(f *builder.File) diag.Diagnostics { diff --git a/converter/internal/common/validate_test.go b/converter/internal/common/validate_test.go new file mode 100644 index 000000000000..6f6ce0dbc632 --- /dev/null +++ b/converter/internal/common/validate_test.go @@ -0,0 +1,122 @@ +package common_test + +import ( + "fmt" + "testing" + + "github.com/grafana/agent/converter/diag" + "github.com/grafana/agent/converter/internal/common" + "github.com/stretchr/testify/require" +) + +func TestInvalidValidationType(t *testing.T) { + diags := common.ValidateSupported(-1, nil, nil, "", "") + require.Len(t, diags, 1) + var expectedDiags diag.Diagnostics + expectedDiags.Add(diag.SeverityLevelCritical, "Invalid converter validation type was requested: -1.") + require.Equal(t, expectedDiags, diags) +} + +func TestValidateSupported(t *testing.T) { + tt := []struct { + tcName string + validationType int + value1 any + value2 any + name string + message string + expectDiag bool + }{ + { + tcName: "Unsupported Equals", + validationType: common.Equals, + value1: "match", + value2: "match", + name: "test", + message: "", + expectDiag: true, + }, + { + tcName: "Supported Equals", + validationType: common.Equals, + value1: "not", + value2: "match", + name: "test", + message: "", + expectDiag: false, + }, + { + tcName: "Unsupported NotEquals", + validationType: common.NotEquals, + value1: "not", + value2: "match", + name: "test", + message: "message", + expectDiag: true, + }, + { + tcName: "Supported NotEquals", + validationType: common.NotEquals, + value1: "match", + value2: "match", + name: "test", + message: "message", + expectDiag: false, + }, + { + tcName: "Unsupported DeepEquals", + validationType: common.DeepEquals, + value1: []string{"match"}, + value2: []string{"match"}, + name: "test", + message: "", + expectDiag: true, + }, + { + tcName: "Supported DeepEquals", + validationType: common.DeepEquals, + value1: []string{"not"}, + value2: []string{"match"}, + name: "test", + message: "message", + expectDiag: false, + }, + { + tcName: "Supported NotDeepEquals", + validationType: common.NotDeepEquals, + value1: []string{"not"}, + value2: []string{"match"}, + name: "test", + message: "", + expectDiag: true, + }, + { + tcName: "Supported NotDeepEquals", + validationType: common.NotDeepEquals, + value1: []string{"match"}, + value2: []string{"match"}, + name: "test", + message: "message", + expectDiag: false, + }, + } + + for _, tc := range tt { + t.Run(tc.tcName, func(t *testing.T) { + diags := common.ValidateSupported(tc.validationType, tc.value1, tc.value2, tc.name, tc.message) + if tc.expectDiag { + require.Len(t, diags, 1) + var expectedDiags diag.Diagnostics + if tc.message != "" { + expectedDiags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s config: %s", tc.name, tc.message)) + } else { + expectedDiags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s config.", tc.name)) + } + + require.Equal(t, expectedDiags, diags) + } else { + require.Len(t, diags, 0) + } + }) + } +} diff --git a/converter/internal/prometheusconvert/component/digitalocean.go b/converter/internal/prometheusconvert/component/digitalocean.go index 2529442bfa22..1b8be57618b6 100644 --- a/converter/internal/prometheusconvert/component/digitalocean.go +++ b/converter/internal/prometheusconvert/component/digitalocean.go @@ -1,7 +1,6 @@ package component import ( - "reflect" "time" "github.com/grafana/agent/component/common/config" @@ -26,21 +25,14 @@ func appendDiscoveryDigitalOcean(pb *build.PrometheusBlocks, label string, sdCon func ValidateDiscoveryDigitalOcean(sdConfig *prom_digitalocean.SDConfig) diag.Diagnostics { var diags diag.Diagnostics - if sdConfig.HTTPClientConfig.BasicAuth != nil { - diags.Add(diag.SeverityLevelError, "unsupported basic_auth for digitalocean_sd_configs") - } - - if sdConfig.HTTPClientConfig.Authorization != nil { - diags.Add(diag.SeverityLevelError, "unsupported authorization for digitalocean_sd_configs") - } + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 - if sdConfig.HTTPClientConfig.OAuth2 != nil { - diags.Add(diag.SeverityLevelError, "unsupported oauth2 for digitalocean_sd_configs") - } - - if !reflect.DeepEqual(prom_config.TLSConfig{}, sdConfig.HTTPClientConfig.TLSConfig) { - diags.Add(diag.SeverityLevelError, "unsupported oauth2 for digitalocean_sd_configs") - } + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "digitalocean_sd_configs basic_auth", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "digitalocean_sd_configs authorization", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "digitalocean_sd_configs oauth2", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.TLSConfig, prom_config.TLSConfig{}, "digitalocean_sd_configs tls_config", "")) diags.AddAll(common.ValidateHttpClientConfig(&sdConfig.HTTPClientConfig)) diff --git a/converter/internal/prometheusconvert/component/docker.go b/converter/internal/prometheusconvert/component/docker.go index 206cf9fdf415..3dd4faa30665 100644 --- a/converter/internal/prometheusconvert/component/docker.go +++ b/converter/internal/prometheusconvert/component/docker.go @@ -8,10 +8,10 @@ import ( "github.com/grafana/agent/converter/diag" "github.com/grafana/agent/converter/internal/common" "github.com/grafana/agent/converter/internal/prometheusconvert/build" - prom_docker "github.com/prometheus/prometheus/discovery/moby" + prom_moby "github.com/prometheus/prometheus/discovery/moby" ) -func appendDiscoveryDocker(pb *build.PrometheusBlocks, label string, sdConfig *prom_docker.DockerSDConfig) discovery.Exports { +func appendDiscoveryDocker(pb *build.PrometheusBlocks, label string, sdConfig *prom_moby.DockerSDConfig) discovery.Exports { discoveryDockerArgs := toDiscoveryDocker(sdConfig) name := []string{"discovery", "docker"} block := common.NewBlockWithOverride(name, label, discoveryDockerArgs) @@ -19,11 +19,11 @@ func appendDiscoveryDocker(pb *build.PrometheusBlocks, label string, sdConfig *p return common.NewDiscoveryExports("discovery.docker." + label + ".targets") } -func ValidateDiscoveryDocker(sdConfig *prom_docker.DockerSDConfig) diag.Diagnostics { +func ValidateDiscoveryDocker(sdConfig *prom_moby.DockerSDConfig) diag.Diagnostics { return common.ValidateHttpClientConfig(&sdConfig.HTTPClientConfig) } -func toDiscoveryDocker(sdConfig *prom_docker.DockerSDConfig) *docker.Arguments { +func toDiscoveryDocker(sdConfig *prom_moby.DockerSDConfig) *docker.Arguments { if sdConfig == nil { return nil } @@ -38,7 +38,7 @@ func toDiscoveryDocker(sdConfig *prom_docker.DockerSDConfig) *docker.Arguments { } } -func toDockerFilters(filtersConfig []prom_docker.Filter) []docker.Filter { +func toDockerFilters(filtersConfig []prom_moby.Filter) []docker.Filter { filters := make([]docker.Filter, 0) for _, filter := range filtersConfig { diff --git a/converter/internal/prometheusconvert/component/ec2.go b/converter/internal/prometheusconvert/component/ec2.go index f7f820ce98d9..acd89755d165 100644 --- a/converter/internal/prometheusconvert/component/ec2.go +++ b/converter/internal/prometheusconvert/component/ec2.go @@ -1,7 +1,6 @@ package component import ( - "reflect" "time" "github.com/grafana/agent/component/discovery" @@ -25,41 +24,22 @@ func appendDiscoveryEC2(pb *build.PrometheusBlocks, label string, sdConfig *prom func ValidateDiscoveryEC2(sdConfig *prom_aws.EC2SDConfig) diag.Diagnostics { var diags diag.Diagnostics - if sdConfig.HTTPClientConfig.BasicAuth != nil { - diags.Add(diag.SeverityLevelError, "unsupported basic_auth for ec2_sd_configs") - } - - if sdConfig.HTTPClientConfig.Authorization != nil { - diags.Add(diag.SeverityLevelError, "unsupported authorization for ec2_sd_configs") - } - - if sdConfig.HTTPClientConfig.OAuth2 != nil { - diags.Add(diag.SeverityLevelError, "unsupported oauth2 for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken) { - diags.Add(diag.SeverityLevelError, "unsupported bearer_token for ec2_sd_configs") - } + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile) { - diags.Add(diag.SeverityLevelError, "unsupported bearer_token_file for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects) { - diags.Add(diag.SeverityLevelError, "unsupported follow_redirects for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.EnableHTTP2, prom_config.DefaultHTTPClientConfig.EnableHTTP2) { - diags.Add(diag.SeverityLevelError, "unsupported enable_http2 for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.ProxyConfig, prom_config.DefaultHTTPClientConfig.ProxyConfig) { - diags.Add(diag.SeverityLevelError, "unsupported proxy for ec2_sd_configs") - } + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "ec2_sd_configs basic_auth", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "ec2_sd_configs authorization", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "ec2_sd_configs oauth2", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken, "ec2_sd_configs bearer_token", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile, "ec2_sd_configs bearer_token_file", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects, "ec2_sd_configs follow_redirects", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.EnableHTTP2, prom_config.DefaultHTTPClientConfig.EnableHTTP2, "ec2_sd_configs enable_http2", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.ProxyConfig, prom_config.DefaultHTTPClientConfig.ProxyConfig, "ec2_sd_configs proxy", "")) // Do a last check in case any of the specific checks missed anything. - if len(diags) == 0 && !reflect.DeepEqual(sdConfig.HTTPClientConfig, prom_config.DefaultHTTPClientConfig) { - diags.Add(diag.SeverityLevelError, "unsupported http_client_config for ec2_sd_configs") + if len(diags) == 0 { + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig, prom_config.DefaultHTTPClientConfig, "ec2_sd_configs http_client_config", "")) } return diags diff --git a/converter/internal/prometheusconvert/component/lightsail.go b/converter/internal/prometheusconvert/component/lightsail.go index b796502d9a53..10480bd082ff 100644 --- a/converter/internal/prometheusconvert/component/lightsail.go +++ b/converter/internal/prometheusconvert/component/lightsail.go @@ -1,7 +1,6 @@ package component import ( - "reflect" "time" "github.com/grafana/agent/component/discovery" @@ -25,41 +24,22 @@ func appendDiscoveryLightsail(pb *build.PrometheusBlocks, label string, sdConfig func ValidateDiscoveryLightsail(sdConfig *prom_aws.LightsailSDConfig) diag.Diagnostics { var diags diag.Diagnostics - if sdConfig.HTTPClientConfig.BasicAuth != nil { - diags.Add(diag.SeverityLevelError, "unsupported basic_auth for ec2_sd_configs") - } - - if sdConfig.HTTPClientConfig.Authorization != nil { - diags.Add(diag.SeverityLevelError, "unsupported authorization for ec2_sd_configs") - } - - if sdConfig.HTTPClientConfig.OAuth2 != nil { - diags.Add(diag.SeverityLevelError, "unsupported oauth2 for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken) { - diags.Add(diag.SeverityLevelError, "unsupported bearer_token for ec2_sd_configs") - } + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile) { - diags.Add(diag.SeverityLevelError, "unsupported bearer_token_file for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects) { - diags.Add(diag.SeverityLevelError, "unsupported follow_redirects for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.EnableHTTP2, prom_config.DefaultHTTPClientConfig.EnableHTTP2) { - diags.Add(diag.SeverityLevelError, "unsupported enable_http2 for ec2_sd_configs") - } - - if !reflect.DeepEqual(sdConfig.HTTPClientConfig.ProxyConfig, prom_config.DefaultHTTPClientConfig.ProxyConfig) { - diags.Add(diag.SeverityLevelError, "unsupported proxy for ec2_sd_configs") - } + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "lightsail_sd_configs basic_auth", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "lightsail_sd_configs authorization", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "lightsail_sd_configs oauth2", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken, "lightsail_sd_configs bearer_token", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile, "lightsail_sd_configs bearer_token_file", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects, "lightsail_sd_configs follow_redirects", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.EnableHTTP2, prom_config.DefaultHTTPClientConfig.EnableHTTP2, "lightsail_sd_configs enable_http2", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig.ProxyConfig, prom_config.DefaultHTTPClientConfig.ProxyConfig, "lightsail_sd_configs proxy", "")) // Do a last check in case any of the specific checks missed anything. - if len(diags) == 0 && !reflect.DeepEqual(sdConfig.HTTPClientConfig, prom_config.DefaultHTTPClientConfig) { - diags.Add(diag.SeverityLevelError, "unsupported http_client_config for ec2_sd_configs") + if len(diags) == 0 { + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, sdConfig.HTTPClientConfig, prom_config.DefaultHTTPClientConfig, "lightsail_sd_configs http_client_config", "")) } return diags diff --git a/converter/internal/prometheusconvert/component/scrape.go b/converter/internal/prometheusconvert/component/scrape.go index d115bbb09cf0..096276e36057 100644 --- a/converter/internal/prometheusconvert/component/scrape.go +++ b/converter/internal/prometheusconvert/component/scrape.go @@ -29,10 +29,7 @@ func AppendPrometheusScrape(pb *build.PrometheusBlocks, scrapeConfig *prom_confi func ValidatePrometheusScrape(scrapeConfig *prom_config.ScrapeConfig) diag.Diagnostics { var diags diag.Diagnostics - if scrapeConfig.NativeHistogramBucketLimit != 0 { - diags.Add(diag.SeverityLevelError, "unsupported native_histogram_bucket_limit for scrape_configs") - } - + diags.AddAll(common.ValidateSupported(common.NotEquals, scrapeConfig.NativeHistogramBucketLimit, uint(0), "scrape_configs native_histogram_bucket_limit", "")) diags.AddAll(common.ValidateHttpClientConfig(&scrapeConfig.HTTPClientConfig)) return diags diff --git a/converter/internal/prometheusconvert/component/service_discovery.go b/converter/internal/prometheusconvert/component/service_discovery.go index 75c84c86ad34..578c9f540fae 100644 --- a/converter/internal/prometheusconvert/component/service_discovery.go +++ b/converter/internal/prometheusconvert/component/service_discovery.go @@ -147,7 +147,7 @@ func ValidateServiceDiscoveryConfig(serviceDiscoveryConfig prom_discover.Config) return ValidateDiscoveryDockerswarm(sdc) default: var diags diag.Diagnostics - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported service discovery %s was provided", serviceDiscoveryConfig.Name())) + diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s service discovery.", serviceDiscoveryConfig.Name())) return diags } } diff --git a/converter/internal/prometheusconvert/testdata/digitalocean.diags b/converter/internal/prometheusconvert/testdata/digitalocean.diags index 3293953af070..192d5c8d858e 100644 --- a/converter/internal/prometheusconvert/testdata/digitalocean.diags +++ b/converter/internal/prometheusconvert/testdata/digitalocean.diags @@ -1,3 +1,3 @@ -(Error) unsupported basic_auth for digitalocean_sd_configs -(Error) unsupported HTTP Client config proxy_from_environment was provided -(Error) unsupported HTTP Client config proxy_from_environment was provided \ No newline at end of file +(Error) The converter does not support converting the provided digitalocean_sd_configs basic_auth config. +(Error) The converter does not support converting the provided HTTP Client proxy_from_environment config. +(Error) The converter does not support converting the provided HTTP Client proxy_from_environment config. \ No newline at end of file diff --git a/converter/internal/prometheusconvert/testdata/ec2.diags b/converter/internal/prometheusconvert/testdata/ec2.diags index 2d1991f1be31..3301a9ad2213 100644 --- a/converter/internal/prometheusconvert/testdata/ec2.diags +++ b/converter/internal/prometheusconvert/testdata/ec2.diags @@ -1 +1 @@ -(Error) unsupported bearer_token_file for ec2_sd_configs \ No newline at end of file +(Error) The converter does not support converting the provided ec2_sd_configs bearer_token_file config. \ No newline at end of file diff --git a/converter/internal/prometheusconvert/testdata/lightsail.diags b/converter/internal/prometheusconvert/testdata/lightsail.diags index 2d1991f1be31..0a96d20e3985 100644 --- a/converter/internal/prometheusconvert/testdata/lightsail.diags +++ b/converter/internal/prometheusconvert/testdata/lightsail.diags @@ -1 +1 @@ -(Error) unsupported bearer_token_file for ec2_sd_configs \ No newline at end of file +(Error) The converter does not support converting the provided lightsail_sd_configs bearer_token_file config. \ No newline at end of file diff --git a/converter/internal/prometheusconvert/testdata/unsupported.diags b/converter/internal/prometheusconvert/testdata/unsupported.diags index 6ea410da9bc5..ccdf9bd3da88 100644 --- a/converter/internal/prometheusconvert/testdata/unsupported.diags +++ b/converter/internal/prometheusconvert/testdata/unsupported.diags @@ -1,12 +1,12 @@ -(Error) unsupported global evaluation_interval config was provided -(Error) unsupported global query_log_file config was provided -(Error) unsupported alerting config was provided -(Error) unsupported rule_files config was provided -(Error) unsupported HTTP Client config no_proxy was provided -(Error) unsupported service discovery nomad was provided -(Error) unsupported native_histogram_bucket_limit for scrape_configs -(Error) unsupported storage config was provided -(Error) unsupported tracing config was provided -(Error) unsupported HTTP Client config proxy_from_environment was provided -(Error) unsupported HTTP Client config max_version was provided -(Error) unsupported remote_read config was provided \ No newline at end of file +(Error) The converter does not support converting the provided global evaluation_interval config. +(Error) The converter does not support converting the provided global query_log_file config. +(Error) The converter does not support converting the provided alerting config. +(Error) The converter does not support converting the provided rule_files config. +(Error) The converter does not support converting the provided HTTP Client no_proxy config. +(Error) The converter does not support converting the provided nomad service discovery. +(Error) The converter does not support converting the provided scrape_configs native_histogram_bucket_limit config. +(Error) The converter does not support converting the provided storage config. +(Error) The converter does not support converting the provided tracing config. +(Error) The converter does not support converting the provided HTTP Client proxy_from_environment config. +(Error) The converter does not support converting the provided HTTP Client max_version config. +(Error) The converter does not support converting the provided remote_read config. \ No newline at end of file diff --git a/converter/internal/prometheusconvert/validate.go b/converter/internal/prometheusconvert/validate.go index fefc991e0df0..de6c6a46e11a 100644 --- a/converter/internal/prometheusconvert/validate.go +++ b/converter/internal/prometheusconvert/validate.go @@ -1,9 +1,8 @@ package prometheusconvert import ( - "reflect" - "github.com/grafana/agent/converter/diag" + "github.com/grafana/agent/converter/internal/common" "github.com/grafana/agent/converter/internal/prometheusconvert/component" prom_config "github.com/prometheus/prometheus/config" prom_discover "github.com/prometheus/prometheus/discovery" @@ -26,33 +25,20 @@ func validate(promConfig *prom_config.Config) diag.Diagnostics { func validateGlobalConfig(globalConfig *prom_config.GlobalConfig) diag.Diagnostics { var diags diag.Diagnostics - if globalConfig.EvaluationInterval != prom_config.DefaultGlobalConfig.EvaluationInterval { - diags.Add(diag.SeverityLevelError, "unsupported global evaluation_interval config was provided") - } - if globalConfig.QueryLogFile != "" { - diags.Add(diag.SeverityLevelError, "unsupported global query_log_file config was provided") - } + diags.AddAll(common.ValidateSupported(common.NotEquals, globalConfig.EvaluationInterval, prom_config.DefaultGlobalConfig.EvaluationInterval, "global evaluation_interval", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, globalConfig.QueryLogFile, "", "global query_log_file", "")) return diags } func validateAlertingConfig(alertingConfig *prom_config.AlertingConfig) diag.Diagnostics { - var diags diag.Diagnostics - if len(alertingConfig.AlertmanagerConfigs) > 0 || len(alertingConfig.AlertRelabelConfigs) > 0 { - diags.Add(diag.SeverityLevelError, "unsupported alerting config was provided") - } - - return diags + hasAlerting := len(alertingConfig.AlertmanagerConfigs) > 0 || len(alertingConfig.AlertRelabelConfigs) > 0 + return common.ValidateSupported(common.Equals, hasAlerting, true, "alerting", "") } func validateRuleFilesConfig(ruleFilesConfig []string) diag.Diagnostics { - var diags diag.Diagnostics - if len(ruleFilesConfig) > 0 { - diags.Add(diag.SeverityLevelError, "unsupported rule_files config was provided") - } - - return diags + return common.ValidateSupported(common.Equals, len(ruleFilesConfig) > 0, true, "rule_files", "") } func validateScrapeConfigs(scrapeConfigs []*prom_config.ScrapeConfig) diag.Diagnostics { @@ -76,21 +62,12 @@ func ValidateServiceDiscoveryConfigs(serviceDiscoveryConfigs prom_discover.Confi } func validateStorageConfig(storageConfig *prom_config.StorageConfig) diag.Diagnostics { - var diags diag.Diagnostics - if storageConfig.TSDBConfig != nil || storageConfig.ExemplarsConfig != nil { - diags.Add(diag.SeverityLevelError, "unsupported storage config was provided") - } - - return diags + hasStorage := storageConfig.TSDBConfig != nil || storageConfig.ExemplarsConfig != nil + return common.ValidateSupported(common.Equals, hasStorage, true, "storage", "") } func validateTracingConfig(tracingConfig *prom_config.TracingConfig) diag.Diagnostics { - var diags diag.Diagnostics - if !reflect.DeepEqual(*tracingConfig, prom_config.TracingConfig{}) { - diags.Add(diag.SeverityLevelError, "unsupported tracing config was provided") - } - - return diags + return common.ValidateSupported(common.NotDeepEquals, *tracingConfig, prom_config.TracingConfig{}, "tracing", "") } func validateRemoteWriteConfigs(remoteWriteConfigs []*prom_config.RemoteWriteConfig) diag.Diagnostics { @@ -104,10 +81,5 @@ func validateRemoteWriteConfigs(remoteWriteConfigs []*prom_config.RemoteWriteCon } func validateRemoteReadConfigs(remoteReadConfigs []*prom_config.RemoteReadConfig) diag.Diagnostics { - var diags diag.Diagnostics - if len(remoteReadConfigs) > 0 { - diags.Add(diag.SeverityLevelError, "unsupported remote_read config was provided") - } - - return diags + return common.ValidateSupported(common.Equals, len(remoteReadConfigs) > 0, true, "remote_read", "") } diff --git a/converter/internal/promtailconvert/internal/build/stages.go b/converter/internal/promtailconvert/internal/build/stages.go index 85ec697603cd..93d6030bb72f 100644 --- a/converter/internal/promtailconvert/internal/build/stages.go +++ b/converter/internal/promtailconvert/internal/build/stages.go @@ -91,7 +91,7 @@ func convertStage(st interface{}, diags *diag.Diagnostics) (stages.StageConfig, } } - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported pipeline stage: %v", st)) + diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided pipeline stage: %v", st)) return stages.StageConfig{}, false } diff --git a/converter/internal/promtailconvert/testdata/kubernetes.diags b/converter/internal/promtailconvert/testdata/kubernetes.diags index e766329835fd..33784fc0f6a3 100644 --- a/converter/internal/promtailconvert/testdata/kubernetes.diags +++ b/converter/internal/promtailconvert/testdata/kubernetes.diags @@ -1 +1 @@ -(Error) unsupported HTTP Client config proxy_from_environment was provided \ No newline at end of file +(Error) The converter does not support converting the provided HTTP Client proxy_from_environment config. \ No newline at end of file diff --git a/converter/internal/promtailconvert/testdata/unsupported.diags b/converter/internal/promtailconvert/testdata/unsupported.diags index 5817deddadb1..f5acdc0b2087 100644 --- a/converter/internal/promtailconvert/testdata/unsupported.diags +++ b/converter/internal/promtailconvert/testdata/unsupported.diags @@ -1,10 +1,9 @@ -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory (Error) Promtail's WAL is currently not supported in Flow Mode (Error) limits_config is not yet supported in Flow Mode (Warning) If you have a tracing set up for Promtail, it cannot be migrated to Flow Mode automatically. Refer to the documentation on how to configure tracing in Flow Mode. (Error) reading targets from stdin is not supported in Flow Mode configuration file (Warning) server.profiling_enabled is not supported - use Agent's main HTTP server's profiling endpoints instead (Warning) The Agent's Flow Mode metrics are different from the metrics emitted by Promtail. If you rely on Promtail's metrics, you must change your configuration, for example, your alerts and dashboards. -(Warning) server.log_level is not supported - Flow mode components may produce different logs +(Warning) The converter does not support converting the provided server.log_level config: The equivalent feature in Flow mode is to use the logging config block to set the level argument. (Error) server.http_path_prefix is not supported (Warning) server.health_check_target disabling is not supported in Flow mode \ No newline at end of file diff --git a/converter/internal/promtailconvert/validate.go b/converter/internal/promtailconvert/validate.go index 9c4a2a1f0270..817601d48607 100644 --- a/converter/internal/promtailconvert/validate.go +++ b/converter/internal/promtailconvert/validate.go @@ -11,7 +11,7 @@ func validateTopLevelConfig(cfg *promtailcfg.Config, diags *diag.Diagnostics) { // The positions global config is not supported in Flow Mode. if cfg.PositionsConfig != DefaultPositionsConfig() { diags.Add( - diag.SeverityLevelWarn, + diag.SeverityLevelInfo, "global positions configuration is not supported - each Flow Mode's loki.source.file component "+ "has its own positions file in the component's data directory", ) @@ -67,8 +67,8 @@ func validateTopLevelConfig(cfg *promtailcfg.Config, diags *diag.Diagnostics) { } if cfg.ServerConfig.LogLevel.String() != "info" { - diags.Add(diag.SeverityLevelWarn, "server.log_level is not supported - Flow mode "+ - "components may produce different logs") + diags.Add(diag.SeverityLevelWarn, "The converter does not support converting the provided server.log_level config: "+ + "The equivalent feature in Flow mode is to use the logging config block to set the level argument.") } if cfg.ServerConfig.PathPrefix != "" { diff --git a/converter/internal/staticconvert/internal/build/builder.go b/converter/internal/staticconvert/internal/build/builder.go index 9e99a619d32f..939592a6a2b2 100644 --- a/converter/internal/staticconvert/internal/build/builder.go +++ b/converter/internal/staticconvert/internal/build/builder.go @@ -73,7 +73,7 @@ func (b *IntegrationsV1ConfigBuilder) appendIntegrations() { } if !scrapeIntegration { - b.diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported integration which is not being scraped was provided: %s.", integration.Name())) + b.diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support handling integrations which are not being scraped: %s.", integration.Name())) continue } diff --git a/converter/internal/staticconvert/staticconvert.go b/converter/internal/staticconvert/staticconvert.go index 2babe6724f4c..fd4c1df90340 100644 --- a/converter/internal/staticconvert/staticconvert.go +++ b/converter/internal/staticconvert/staticconvert.go @@ -129,6 +129,12 @@ func appendStaticPromtail(f *builder.File, staticConfig *config.Config) diag.Dia promtailConfig.TargetConfig = logConfig.TargetConfig promtailConfig.LimitsConfig = logConfig.LimitsConfig + // We are using the + err := promtailConfig.ServerConfig.Config.LogLevel.Set("info") + if err != nil { + panic("unable to set default promtail log level from the static converter.") + } + // We need to set this when empty so the promtail converter doesn't think it has been overridden if promtailConfig.Global == (promtail_config.GlobalConfig{}) { promtailConfig.Global.FileWatch = file.DefaultWatchConig diff --git a/converter/internal/staticconvert/testdata/prom_scrape.diags b/converter/internal/staticconvert/testdata/prom_scrape.diags index 109165d53b8c..8cd4f240ac16 100644 --- a/converter/internal/staticconvert/testdata/prom_scrape.diags +++ b/converter/internal/staticconvert/testdata/prom_scrape.diags @@ -1,3 +1,3 @@ -(Error) unsupported global evaluation_interval config was provided +(Error) The converter does not support converting the provided global evaluation_interval config. (Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. -(Error) unsupported wal_directory metrics config was provided. use the run command flag --storage.path for Flow mode instead. \ No newline at end of file +(Warning) The converter does not support converting the provided metrics wal_directory config: Use the run command flag --storage.path for Flow mode instead. \ No newline at end of file diff --git a/converter/internal/staticconvert/testdata/promtail_prom.diags b/converter/internal/staticconvert/testdata/promtail_prom.diags index 7e904606cb92..a4a05d1a3b58 100644 --- a/converter/internal/staticconvert/testdata/promtail_prom.diags +++ b/converter/internal/staticconvert/testdata/promtail_prom.diags @@ -1,5 +1 @@ -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) server.log_level is not supported - Flow mode components may produce different logs -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) server.log_level is not supported - Flow mode components may produce different logs (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/promtail_scrape.diags b/converter/internal/staticconvert/testdata/promtail_scrape.diags index 76cf523456b8..a4a05d1a3b58 100644 --- a/converter/internal/staticconvert/testdata/promtail_scrape.diags +++ b/converter/internal/staticconvert/testdata/promtail_scrape.diags @@ -1,3 +1 @@ -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) server.log_level is not supported - Flow mode components may produce different logs (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/sanitize.diags b/converter/internal/staticconvert/testdata/sanitize.diags index e57dd99a6aa2..484554168237 100644 --- a/converter/internal/staticconvert/testdata/sanitize.diags +++ b/converter/internal/staticconvert/testdata/sanitize.diags @@ -1,5 +1,3 @@ -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) server.log_level is not supported - Flow mode components may produce different logs (Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. -(Error) unsupported wal_directory metrics config was provided. use the run command flag --storage.path for Flow mode instead. -(Error) unsupported integration agent was provided. \ No newline at end of file +(Warning) The converter does not support converting the provided metrics wal_directory config: Use the run command flag --storage.path for Flow mode instead. +(Error) The converter does not support converting the provided agent integration. \ No newline at end of file diff --git a/converter/internal/staticconvert/testdata/unsupported.diags b/converter/internal/staticconvert/testdata/unsupported.diags index 1e3ec0f4f371..7fde45c4ed71 100644 --- a/converter/internal/staticconvert/testdata/unsupported.diags +++ b/converter/internal/staticconvert/testdata/unsupported.diags @@ -1,12 +1,10 @@ -(Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) server.log_level is not supported - Flow mode components may produce different logs -(Error) unsupported integration which is not being scraped was provided: mssql. +(Error) The converter does not support handling integrations which are not being scraped: mssql. (Error) mapping_config is not supported in statsd_exporter integrations config (Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. -(Error) unsupported grpc_tls_config server config was provided: flow mode does not have a gRPC server to configure. -(Error) unsupported prefer_server_cipher_suites server config was provided. -(Error) unsupported wal_directory metrics config was provided. use the run command flag --storage.path for Flow mode instead. -(Error) unsupported integration agent was provided. +(Error) The converter does not support converting the provided grpc_tls_config server config: flow mode does not have a gRPC server to configure. +(Error) The converter does not support converting the provided prefer_server_cipher_suites server config. +(Warning) The converter does not support converting the provided metrics wal_directory config: Use the run command flag --storage.path for Flow mode instead. +(Error) The converter does not support converting the provided agent integration. (Warning) disabled integrations do nothing and are not included in the output: node_exporter. -(Error) unsupported traces config was provided. -(Error) unsupported agent_management config was provided. \ No newline at end of file +(Error) The converter does not support converting the provided traces config. +(Error) The converter does not support converting the provided agent_management config. \ No newline at end of file diff --git a/converter/internal/staticconvert/validate.go b/converter/internal/staticconvert/validate.go index 8f2eb027a93b..13a583456b68 100644 --- a/converter/internal/staticconvert/validate.go +++ b/converter/internal/staticconvert/validate.go @@ -67,8 +67,8 @@ func validateServer(serverConfig *server.Config) diag.Diagnostics { var diags diag.Diagnostics defaultServerConfig := server.DefaultConfig() - diags.AddAll(common.UnsupportedNotDeepEqualsMessage(serverConfig.GRPC, defaultServerConfig.GRPC, "grpc_tls_config server", "flow mode does not have a gRPC server to configure.")) - diags.AddAll(common.UnsupportedNotEquals(serverConfig.HTTP.TLSConfig.PreferServerCipherSuites, defaultServerConfig.HTTP.TLSConfig.PreferServerCipherSuites, "prefer_server_cipher_suites server")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, serverConfig.GRPC, defaultServerConfig.GRPC, "grpc_tls_config server", "flow mode does not have a gRPC server to configure.")) + diags.AddAll(common.ValidateSupported(common.NotEquals, serverConfig.HTTP.TLSConfig.PreferServerCipherSuites, defaultServerConfig.HTTP.TLSConfig.PreferServerCipherSuites, "prefer_server_cipher_suites server", "")) return diags } @@ -80,20 +80,19 @@ func validateMetrics(metricsConfig metrics.Config, grpcListenPort int) diag.Diag defaultMetrics := config.DefaultConfig().Metrics defaultMetrics.ServiceConfig.Lifecycler.ListenPort = grpcListenPort - diags.AddAll(common.UnsupportedNotDeepEquals(metricsConfig.WALCleanupAge, defaultMetrics.WALCleanupAge, "wal_cleanup_age metrics")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, metricsConfig.WALCleanupAge, defaultMetrics.WALCleanupAge, "wal_cleanup_age metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, metricsConfig.WALCleanupPeriod, defaultMetrics.WALCleanupPeriod, "wal_cleanup_period metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, metricsConfig.ServiceConfig, defaultMetrics.ServiceConfig, "scraping_service metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, metricsConfig.ServiceClientConfig, defaultMetrics.ServiceClientConfig, "scraping_service_client metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, metricsConfig.InstanceRestartBackoff, defaultMetrics.InstanceRestartBackoff, "instance_restart_backoff metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, metricsConfig.InstanceMode, defaultMetrics.InstanceMode, "instance_mode metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, metricsConfig.DisableKeepAlives, defaultMetrics.DisableKeepAlives, "http_disable_keepalives metrics", "")) + diags.AddAll(common.ValidateSupported(common.NotEquals, metricsConfig.IdleConnTimeout, defaultMetrics.IdleConnTimeout, "http_idle_conn_timeout metrics", "")) if metricsConfig.WALDir != defaultMetrics.WALDir { - diags.Add(diag.SeverityLevelError, "unsupported wal_directory metrics config was provided. use the run command flag --storage.path for Flow mode instead.") + diags.Add(diag.SeverityLevelWarn, "The converter does not support converting the provided metrics wal_directory config: Use the run command flag --storage.path for Flow mode instead.") } - diags.AddAll(common.UnsupportedNotEquals(metricsConfig.WALCleanupPeriod, defaultMetrics.WALCleanupPeriod, "wal_cleanup_period metrics")) - diags.AddAll(common.UnsupportedNotDeepEquals(metricsConfig.ServiceConfig, defaultMetrics.ServiceConfig, "scraping_service metrics")) - diags.AddAll(common.UnsupportedNotDeepEquals(metricsConfig.ServiceClientConfig, defaultMetrics.ServiceClientConfig, "scraping_service_client metrics")) - diags.AddAll(common.UnsupportedNotEquals(metricsConfig.InstanceRestartBackoff, defaultMetrics.InstanceRestartBackoff, "instance_restart_backoff metrics")) - diags.AddAll(common.UnsupportedNotEquals(metricsConfig.InstanceMode, defaultMetrics.InstanceMode, "instance_mode metrics")) - diags.AddAll(common.UnsupportedNotEquals(metricsConfig.DisableKeepAlives, defaultMetrics.DisableKeepAlives, "http_disable_keepalives metrics")) - diags.AddAll(common.UnsupportedNotEquals(metricsConfig.IdleConnTimeout, defaultMetrics.IdleConnTimeout, "http_idle_conn_timeout metrics")) - return diags } @@ -133,7 +132,7 @@ func validateIntegrations(integrationsConfig config.VersionedIntegrations) diag. case *azure_exporter.Config: case *cadvisor.Config: default: - diags.Add(diag.SeverityLevelError, fmt.Sprintf("unsupported integration %s was provided.", itg.Name())) + diags.Add(diag.SeverityLevelError, fmt.Sprintf("The converter does not support converting the provided %s integration.", itg.Name())) } } @@ -143,7 +142,7 @@ func validateIntegrations(integrationsConfig config.VersionedIntegrations) diag. func validateTraces(tracesConfig traces.Config) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotDeepEquals(tracesConfig, traces.Config{}, "traces")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, tracesConfig, traces.Config{}, "traces", "")) return diags } @@ -159,7 +158,7 @@ func validateLogs(logsConfig *logs.Config) diag.Diagnostics { func validateAgentManagement(agentManagementConfig config.AgentManagementConfig) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotDeepEquals(agentManagementConfig, config.AgentManagementConfig{}, "agent_management")) + diags.AddAll(common.ValidateSupported(common.NotDeepEquals, agentManagementConfig, config.AgentManagementConfig{}, "agent_management", "")) return diags } diff --git a/docs/sources/flow/getting-started/migrating-from-static.md b/docs/sources/flow/getting-started/migrating-from-static.md index 39a5889e680f..6d3349b18aea 100644 --- a/docs/sources/flow/getting-started/migrating-from-static.md +++ b/docs/sources/flow/getting-started/migrating-from-static.md @@ -98,8 +98,6 @@ features available in Grafana Agent Flow mode. report provides the following information: ```plaintext - (Warning) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory - (Warning) server.log_level is not supported - Flow mode components may produce different logs (Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. ``` @@ -217,7 +215,7 @@ prometheus.scrape "metrics_test_local_agent" { prometheus.remote_write "metrics_test" { endpoint { - name = "test-a653a1" + name = "test-3a2a1b" url = "https://prometheus-us-central1.grafana.net/api/prom/push" basic_auth {