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 Kubernetes labels normalization for Prometheus #7925

Merged
merged 3 commits into from Dec 14, 2021

Conversation

slok
Copy link
Contributor

@slok slok commented Dec 14, 2021

PR info

Continues from #7374

When we were testing v2.2.0-rc1 and added the label metrics, Argo panicked because of the type of labels we use (Valid in Kubernetes). We use organization.fonoa.io/owner style labels. This was the error:

panic: descriptor Desc{fqName: "argocd_app_labels", help: "Argo Application labels converted to Prometheus labels", constLabels: {}, variableLabels: [namespace name project l
abel_organization.fonoa.io/owner label_runtime.fonoa.io/cluster label_runtime.fonoa.io/environment label_runtime.fonoa.io/service label_runtime.fonoa.io/tier]} is invalid: "l
abel_organization.fonoa.io/owner" is not a valid label name for metric "argocd_app_labels"

This PR solves this by replacing all non-valid Prometheus labels characters with a _ character.

Checklist

This PR is a small fix that

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).

…the invalid Prometheus label chars

Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
@alexmt alexmt requested a review from leoluz December 14, 2021 19:43
Copy link
Collaborator

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #7925 (1ae77cf) into master (bed36e2) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7925   +/-   ##
=======================================
  Coverage   41.48%   41.48%           
=======================================
  Files         169      169           
  Lines       22353    22353           
=======================================
  Hits         9274     9274           
  Misses      11755    11755           
  Partials     1324     1324           
Impacted Files Coverage Δ
controller/metrics/metrics.go 80.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bed36e2...1ae77cf. Read the comment docs.

@alexmt alexmt merged commit 6a14723 into argoproj:master Dec 14, 2021
@slok slok deleted the slok/fix-label-chars-replace branch December 14, 2021 21:03
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

3 participants