Skip to content

feat: update converter to use file_match block#4791

Merged
kalleep merged 4 commits intomainfrom
kalleep/converter-file-match-block
Nov 17, 2025
Merged

feat: update converter to use file_match block#4791
kalleep merged 4 commits intomainfrom
kalleep/converter-file-match-block

Conversation

@kalleep
Copy link
Contributor

@kalleep kalleep commented Nov 6, 2025

PR Description

Now that #4743 is merged we can update converters to use file_match block instead of going through local.file_match.

Which issue(s) this PR fixes

fixes: #4744

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@kalleep kalleep requested a review from a team as a code owner November 6, 2025 12:45
@kalleep kalleep requested a review from Copilot November 6, 2025 14:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the promtail converter to eliminate the intermediate local.file_match component in favor of using the built-in file_match block within loki.source.file. This simplifies the generated Alloy configuration by reducing component indirection.

  • Removed the local.file_match component generation logic
  • Updated code generator to include file_match block directly in loki.source.file
  • Removed unused import and struct fields related to file matching

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/converter/internal/promtailconvert/internal/build/scrape_builder.go Refactored to use inline file_match block instead of separate local.file_match component; removed getExpandedFileTargetsExpr() method and added convertFileMatchConfig() helper
CHANGELOG.md Added enhancement entry documenting the converter update
internal/converter/internal/staticconvert/testdata_linux/promtail_prom.alloy Updated test data to reflect new pattern with inline file_match block
internal/converter/internal/staticconvert/testdata_linux/promtail_metrics.alloy Updated test data to reflect new pattern with inline file_match block
internal/converter/internal/promtailconvert/testdata/*.alloy Updated all test data files (26 files) to use inline file_match block and direct target references instead of local.file_match component

@kalleep kalleep force-pushed the kalleep/converter-file-match-block branch from 01208be to e26ce4f Compare November 10, 2025 08:25
Copy link
Contributor

@ptodev ptodev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not considered experimental, but do we need to do more dogfooding before rolling it out as a default more widely?

@ptodev ptodev self-assigned this Nov 12, 2025
@kalleep
Copy link
Contributor Author

kalleep commented Nov 12, 2025

I know it's not considered experimental, but do we need to do more dogfooding before rolling it out as a default more widely?

Sure we can target next release with this specific change if you are more comfortable with it?

@ptodev
Copy link
Contributor

ptodev commented Nov 12, 2025

Targeting next release would be nice. Especially if for some reason users are translating the config on the latest version, but still expect the previous Alloy version to work with the translated config.

@kalleep kalleep force-pushed the kalleep/converter-file-match-block branch from 0aa5bad to 5d7342c Compare November 17, 2025 08:16
@kalleep kalleep enabled auto-merge (squash) November 17, 2025 10:50
@kalleep kalleep merged commit a42f386 into main Nov 17, 2025
44 of 45 checks passed
@kalleep kalleep deleted the kalleep/converter-file-match-block branch November 17, 2025 11:00
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
* update converter to use file_match block

* Add changelog
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Converters: change to use file_match block in loki.source.file

3 participants