Skip to content

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Jun 10, 2025

Extends the deny-tag middleware to allow denying based on prefix or suffix.

This PR extends the deny-tag middleware that enables filtering of metric tag values by prefix and/or suffix. The primary use case is to reduce metric cardinality by automatically stripping common prefixes/suffixes from tag values in a centralized way.

The main benefits are:

  • A central place to filter out tags vs filter it out on the caller side
  • Reduces the risk of accidentally introducing a high cardinality tag
  • Opt in/out at a central place
  • No need to maintain a allow/deny list, tags can be added using a configured format and will automatically be stripped

@Litarnus Litarnus marked this pull request as ready for review June 11, 2025 11:13
@Litarnus Litarnus requested review from a team and untitaker June 11, 2025 11:13
Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

can this be folded into deny-tag middleware? if not, i'd avoid introducing another verb "strip" and replace it with "deny" (deny-tag-substring or similar

@Litarnus
Copy link
Contributor Author

can this be folded into deny-tag middleware? if not, i'd avoid introducing another verb "strip" and replace it with "deny" (deny-tag-substring or similar

Yes I think that should be possible. I will have a look.

@Litarnus Litarnus requested a review from untitaker June 11, 2025 12:58
Comment on lines +14 to +15
starts_with: [foo]
ends_with: [bar]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking about calling this prefix/suffix, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

no strong opinion, either is fine. i think the "best" API would be to impl glob support in deny-tag, but probably too complicated and possibly slow.

Comment on lines +14 to +15
starts_with: [foo]
ends_with: [bar]
Copy link
Member

Choose a reason for hiding this comment

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

no strong opinion, either is fine. i think the "best" API would be to impl glob support in deny-tag, but probably too complicated and possibly slow.

@Litarnus Litarnus changed the title feat(middleware): add middleware to filter out tags feat(middleware): extend deny middleware to deny based on prefix or suffix Jun 12, 2025
@Litarnus Litarnus merged commit 4450796 into main Jun 12, 2025
5 checks passed
@Litarnus Litarnus deleted the martinl/filter-middleware branch June 12, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants