diff --git a/converter/internal/promtailconvert/internal/build/scrape_builder.go b/converter/internal/promtailconvert/internal/build/scrape_builder.go index 8a4747ad1b1c..c7288be0fc01 100644 --- a/converter/internal/promtailconvert/internal/build/scrape_builder.go +++ b/converter/internal/promtailconvert/internal/build/scrape_builder.go @@ -103,12 +103,13 @@ 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) - // max_cache_size doesnt exist in static, and we need to manually set it to default. - // Else since the go default value will be 0, the IsZero is also 0, so it will assume it should be 0 when comparing - // in appendblock. The check against the default value of 10_000 ensures it will always be written as 0. - args.MaxCacheSize = 10_000 s.f.Body().AppendBlock(common.NewBlockWithOverride([]string{"loki", "relabel"}, compLabel, args)) s.lokiRelabelReceiverExpr = "[loki.relabel." + compLabel + ".receiver]" }