Skip to content

fix(logfmt): use debug logging instead of error similar to what json plugin does - #20885

Merged
spiridonov merged 3 commits into
grafana:mainfrom
abenbachir:abderb/promtail-logfmt
Apr 7, 2026
Merged

fix(logfmt): use debug logging instead of error similar to what json plugin does#20885
spiridonov merged 3 commits into
grafana:mainfrom
abenbachir:abderb/promtail-logfmt

Conversation

@abenbachir

@abenbachir abenbachir commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
The logfmt pipeline stage no longer logs decode failures at error level; it now logs them at debug level and only when the global Debug flag is enabled, aligning its behavior with other parsing stages.

When we use logfmt fields retreival, errors are dumped to promtail logs polluting logs, these errors are only related to field not found. The JSON parser report these errors as debug so I think logfmt should do the same.

Usage

- match:
    selector: '{service=~".+"}'
    stages:
      - logfmt:
          mapping:
            trace_id:
            user_id:

Which issue(s) this PR fixes:
Fixes #6066

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

Note

Low Risk
Low risk: only changes log level/conditional emission for logfmt decode errors, with no impact on parsing behavior or extracted data.

Overview
The logfmt pipeline stage no longer logs decode failures at error level; it now emits a level.Debug message only when the global Debug flag is enabled.

This reduces log noise from expected/benign logfmt decode issues (e.g., missing fields) while leaving extraction behavior unchanged.

Reviewed by Cursor Bugbot for commit 8296b29. Bugbot is set up for automated code reviews on this repo. Configure here.

@spiridonov

Copy link
Copy Markdown
Contributor

Hey @abenbachir! Please fix the PR title and add a description and the reasoning behind this PR. The PR is very small and I can guess what you were trying to solve, but it is necessary to have complete commit messages and PR descriptions for paper-trail and understanding purposes. Thank you!

@spiridonov spiridonov self-assigned this Apr 6, 2026
@abenbachir abenbachir changed the title [logfmt] set error as debug similar to json parsing Apr 6, 2026
@abenbachir

Copy link
Copy Markdown
Contributor Author

Hey @abenbachir! Please fix the PR title and add a description and the reasoning behind this PR. The PR is very small and I can guess what you were trying to solve, but it is necessary to have complete commit messages and PR descriptions for paper-trail and understanding purposes. Thank you!

thanks, updated the PR.

@spiridonov spiridonov changed the title fix(logfmt) use debug logging instead of error similar to what json plugin does Apr 7, 2026
@spiridonov
spiridonov merged commit c10cc90 into grafana:main Apr 7, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants