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

Metrics-generator can generate metrics with invalid labels #4434

Open
yvrhdn opened this issue Dec 10, 2024 · 3 comments
Open

Metrics-generator can generate metrics with invalid labels #4434

yvrhdn opened this issue Dec 10, 2024 · 3 comments
Labels
good first issue Good for newcomers type/bug Something isn't working

Comments

@yvrhdn
Copy link
Member

yvrhdn commented Dec 10, 2024

Describe the bug

If spans contain attributes that start with a number, the metrics-generator might create metrics with invalid labels. These metrics are rejected by the Prometheus backend when they are being remote written.

Example response from Mimir (with data trimmed):

received a series with an invalid label: '1cloud' series: 'traces_target_info{1cloud=\"...\", ...' (err-mimir-label-invalid)"

Prometheus says the following about metric labels:

Metric labels:

  • Enable Prometheus's dimensional data model to identify any given combination of labels for the same metric name. It identifies a particular dimensional instantiation of that metric (for example: all HTTP requests that used the method POST to the /api/tracks handler). The query language allows filtering and aggregation based on these dimensions.
  • The change of any label's value, including adding or removing labels, will create a new time series.
  • Labels may contain ASCII letters, numbers, as well as underscores. They must match the regex [a-zA-Z_][a-zA-Z0-9_]*.
  • Label names beginning with __ (two "_") are reserved for internal use.
  • Label values may contain any Unicode characters.
  • Labels with an empty label value are considered equivalent to labels that do not exist.

To Reproduce
Steps to reproduce the behavior:

  1. Start Tempo (SHA or version)
  2. Configure metrics-generator to generate span and/or service graphs metrics
  3. Send spans containing attributes with invalid Prometheus label names

Expected behavior
We have a few options, I'm not sure which one is best:

  • try to 'correct' the label, would it make sense to add a prefix in this case?
  • drop the label when the metric is created and report this
  • drop the entire sample when the metric is created and report this

Environment:

  • Infrastructure: [e.g., Kubernetes, bare-metal, laptop]
  • Deployment tool: [e.g., helm, jsonnet]

Additional Context

Similar issue: #4293

@yvrhdn yvrhdn added good first issue Good for newcomers type/bug Something isn't working labels Dec 10, 2024
Copy link
Contributor

github-actions bot commented Feb 9, 2025

This issue has been automatically marked as stale because it has not had any activity in the past 60 days.
The next time this stale check runs, the stale label will be removed if there is new activity. The issue will be closed after 15 days if there is no new activity.
Please apply keepalive label to exempt this Issue.

@github-actions github-actions bot added the stale Used for stale issues / PRs label Feb 9, 2025
@KyriosGN0
Copy link
Contributor

@yvrhdn i think that the second options is the best, has some other prefernece been decided by the Team ?
if not, i would like to try and implement this

@github-actions github-actions bot removed the stale Used for stale issues / PRs label Feb 16, 2025
@javiermolinar
Copy link
Contributor

Dropping the label is consistent with current behavior. We already do that for invalid utf8 encoded runes

err := validateLabelValues(labelValues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants