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

Fix: truncate long label values #432

Merged
merged 1 commit into from
Apr 26, 2023
Merged

Fix: truncate long label values #432

merged 1 commit into from
Apr 26, 2023

Conversation

mem
Copy link
Contributor

@mem mem commented Apr 26, 2023

We generate some label values, so they are not being subject to the constraints the labels provided by the user are.

In order to prevent the metrics from being dropped by Prometheus because the label values exceed the limit, truncate the values that exceed the limit, and replace the last three bytes by '...' to indicate that truncation took place.

For the specific case of certificates with a really long list of Subject Alternate Names (SAN), they end up in a label. It's a list that looks like a.example.org,b.example.org,c.example.org. We could split that list and push each individual value as a separate label value just to avoid hitting the limit. The problem with that approach is that we have seen certificates with over 700+ SANs in the wild, so this strategy would push out 700+ metrics.

We generate some label values, so they are not being subject to the
constraints the labels provided by the user are.

In order to prevent the metrics from being dropped by Prometheus because
the label values exceed the limit, truncate the values that exceed the
limit, and replace the last three bytes by '...' to indicate that
truncation took place.

For the specific case of certificates with a really long list of Subject
Alternate Names (SAN), they end up in a label. It's a list that looks
like `a.example.org,b.example.org,c.example.org`. We _could_ split that
list and push each individual value as a separate label value just to
avoid hitting the limit. The problem with that approach is that we have
seen certificates with over 700+ SANs in the wild, so this strategy would
push out 700+ metrics.

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
@mem mem requested a review from a team as a code owner April 26, 2023 22:46
@mem mem merged commit 77faac5 into main Apr 26, 2023
@mem mem deleted the truncate_long_label_values branch April 26, 2023 23:33
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.

None yet

2 participants