From 356c50cbdf384dd9e09a1dd9f26ecf1b0ee41034 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Tue, 28 Nov 2023 09:52:09 -0500 Subject: [PATCH] max_cache_size was being set to 0 (#5869) * max_cache_size was being set to 0, due to issue where it doesnt exist in static but the default wasnt carrying over to river syntax. In truth we should never write it. * Clean up from PR --- CHANGELOG.md | 2 ++ .../promtailconvert/internal/build/scrape_builder.go | 5 +++++ .../promtailconvert/testdata/cloudflare_relabel.river | 1 - .../promtailconvert/testdata/windowsevents_relabel.river | 1 - .../internal/staticconvert/testdata/promtail_scrape.river | 1 - converter/internal/staticconvert/testdata/sanitize.river | 2 -- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d686873671..01d1f99a8a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -209,6 +209,8 @@ v0.38.0 (2023-11-21) - Fix converter output for prometheus.exporter.windows to not unnecessarily add empty blocks. (@erikbaranowski) +- Fix converter issue with `loki.relabel` and `max_cache_size` being set to 0 instead of default (10_000). (@mattdurham) + ### Other changes - Bump `mysqld_exporter` version to v0.15.0. (@marctc) diff --git a/converter/internal/promtailconvert/internal/build/scrape_builder.go b/converter/internal/promtailconvert/internal/build/scrape_builder.go index fc26d29cc832..c7288be0fc01 100644 --- a/converter/internal/promtailconvert/internal/build/scrape_builder.go +++ b/converter/internal/promtailconvert/internal/build/scrape_builder.go @@ -103,6 +103,11 @@ func (s *ScrapeConfigBuilder) getOrNewLokiRelabel() string { args := lokirelabel.Arguments{ ForwardTo: s.getOrNewProcessStageReceivers(), RelabelConfigs: component.ToFlowRelabelConfigs(s.cfg.RelabelConfigs), + // max_cache_size doesnt exist in static, and we need to manually set it to default. + // Since the default is 10_000 if we didnt set the value, it would compare the default 10k to 0 and emit 0. + // We actually dont want to emit anything since this setting doesnt exist in static, setting to 10k matches the default + // and ensures it doesnt get emitted. + MaxCacheSize: lokirelabel.DefaultArguments.MaxCacheSize, } compLabel := common.LabelForParts(s.globalCtx.LabelPrefix, s.cfg.JobName) s.f.Body().AppendBlock(common.NewBlockWithOverride([]string{"loki", "relabel"}, compLabel, args)) diff --git a/converter/internal/promtailconvert/testdata/cloudflare_relabel.river b/converter/internal/promtailconvert/testdata/cloudflare_relabel.river index 201ce8f30356..014d812eab61 100644 --- a/converter/internal/promtailconvert/testdata/cloudflare_relabel.river +++ b/converter/internal/promtailconvert/testdata/cloudflare_relabel.river @@ -5,7 +5,6 @@ loki.relabel "fun" { source_labels = ["__trail__"] target_label = "__path__" } - max_cache_size = 0 } loki.source.cloudflare "fun" { diff --git a/converter/internal/promtailconvert/testdata/windowsevents_relabel.river b/converter/internal/promtailconvert/testdata/windowsevents_relabel.river index 6fa1b693dc1a..39d28dea7a67 100644 --- a/converter/internal/promtailconvert/testdata/windowsevents_relabel.river +++ b/converter/internal/promtailconvert/testdata/windowsevents_relabel.river @@ -5,7 +5,6 @@ loki.relabel "fun" { source_labels = ["__trail__"] target_label = "__path__" } - max_cache_size = 0 } loki.source.windowsevent "fun" { diff --git a/converter/internal/staticconvert/testdata/promtail_scrape.river b/converter/internal/staticconvert/testdata/promtail_scrape.river index 46efa90bcc9f..22ee8576ed96 100644 --- a/converter/internal/staticconvert/testdata/promtail_scrape.river +++ b/converter/internal/staticconvert/testdata/promtail_scrape.river @@ -5,7 +5,6 @@ loki.relabel "logs_log_config_fun" { source_labels = ["__trail__"] target_label = "__path__" } - max_cache_size = 0 } loki.source.cloudflare "logs_log_config_fun" { diff --git a/converter/internal/staticconvert/testdata/sanitize.river b/converter/internal/staticconvert/testdata/sanitize.river index 38dabad4a85c..1bf214eda874 100644 --- a/converter/internal/staticconvert/testdata/sanitize.river +++ b/converter/internal/staticconvert/testdata/sanitize.river @@ -37,7 +37,6 @@ loki.relabel "logs_integrations_integrations_windows_exporter_application" { source_labels = ["computer"] target_label = "agent_hostname" } - max_cache_size = 0 } loki.source.windowsevent "logs_integrations_integrations_windows_exporter_application" { @@ -75,7 +74,6 @@ loki.relabel "logs_integrations_integrations_windows_exporter_system" { source_labels = ["computer"] target_label = "agent_hostname" } - max_cache_size = 0 } loki.source.windowsevent "logs_integrations_integrations_windows_exporter_system" {