Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimir: Add attributed prefix to labels of cost attribution metrics #10509

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ying-jeanne
Copy link
Contributor

@ying-jeanne ying-jeanne commented Jan 24, 2025

What this PR does

Which issue(s) this PR fixes or relates to

Users can set cost attribution labels for cluster and namespace, which may conflict with existing metrics that include a cluster label. To prevent this, cost attribution labels are prefixed, and the prefix can be removed later in the pipeline using recording rules.

Similar approach is implemented in Loki.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

Copy link
Contributor

github-actions bot commented Jan 24, 2025

@ying-jeanne ying-jeanne marked this pull request as ready for review January 24, 2025 14:05
@ying-jeanne ying-jeanne requested review from tacole02 and a team as code owners January 24, 2025 14:05
CHANGELOG.md Outdated
@@ -5,6 +5,7 @@
### Grafana Mimir

* [FEATURE] Ingester/Distributor: Add support for exporting cost attribution metrics (`cortex_ingester_attributed_active_series`, `cortex_distributor_received_attributed_samples_total`, and `cortex_discarded_attributed_samples_total`) with labels specified by customers to a custom Prometheus registry. This feature enables more flexible billing data tracking. #10269
* [CHANGE] Ingester/Distributor: Prefix cost attribution metric labels with `attributed_` to prevent collisions with system cluster and namespace labels. #10509
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed because this new feature isn't included in any release yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed here 97a5d77

@@ -21,6 +21,7 @@ const (
defaultTrackerName = "cost-attribution"
missingValue = "__missing__"
overflowValue = "__overflow__"
usagePrefix = "attributed"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but I would expect the prefix to be attributed_.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 97a5d77

func addLabelsPrefix(labels []string) []string {
out := make([]string, 0, len(labels))
for _, l := range labels {
out = append(out, strings.Join([]string{usagePrefix, l}, ""))
Copy link
Contributor

@colega colega Jan 29, 2025

Choose a reason for hiding this comment

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

This should be just:

Suggested change
out = append(out, strings.Join([]string{usagePrefix, l}, ""))
out = append(out, usagePrefix + l)

@@ -21,6 +21,7 @@ const (
defaultTrackerName = "cost-attribution"
missingValue = "__missing__"
overflowValue = "__overflow__"
usagePrefix = "attributed_"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why is this called "usagePrefix", but I know naming is hard.
Maybe it could be exportedAttributedLabelPrefix?

@seizethedave seizethedave self-requested a review January 30, 2025 18:38
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