-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(controller): add targetRevision in metric app_info #15143
base: master
Are you sure you want to change the base?
feat(controller): add targetRevision in metric app_info #15143
Conversation
27a3b50
to
0f21375
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #15143 +/- ##
==========================================
- Coverage 49.73% 49.25% -0.49%
==========================================
Files 274 274
Lines 48948 48119 -829
==========================================
- Hits 24343 23699 -644
+ Misses 22230 22076 -154
+ Partials 2375 2344 -31 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and will be nice to have this in.
@alexmt @jessesuen could you please approve this? |
What is the current status of this? |
Would also like to know if / when this will be merged. |
We would also like to see this feature added but when reading up on this there's been a discussion regarding the risk of an explosion of metric cardinality due to the uniqueness of the label |
I could add a revision whitelist as setting: metricRevisions: [master, develop] If branch is not whitelisted -> "other" what do u think? |
I think that if we're about to add this label we should keep all possible values. Adding a feature toggle via e.g. a flag and clearly explaning what the flag does would be another approach. In the end maybe a combination of both approaches? |
Well, the whitelist is a good idea and we could switch off this feature if whitelist is empty. Possible whitelist values:
|
Yes, this makes sense, by coincidence I saw something similar in Comma-separated list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the labels metrics are not exposed. To include them, provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...)'. A single '' can be provided per resource instead to allow any labels, but that has severe performance implications (Example: '=pods=[]'). Additionally, an asterisk () can be provided as a key, which will resolve to all resources, i.e., assuming '--resources=deployments,pods', '==[]' will resolve to '=deployments=[],pods=[*]'. Note that this flag adds another metric called |
3343955
to
a5bada1
Compare
Check latest commits! |
77e1348
to
a7f6844
Compare
Signed-off-by: ebuildy <[email protected]>
379cde4
to
13a5110
Compare
13a5110
to
1afb96b
Compare
Signed-off-by: ebuildy <[email protected]>
1afb96b
to
56b1bcd
Compare
Signed-off-by: Thomas Decaux <[email protected]>
Any news on this? |
+1. any news on this PR? we'd really appreciate this support. |
@@ -384,7 +395,7 @@ func (c *appCollector) collectApps(ch chan<- prometheus.Metric, app *argoappv1.A | |||
|
|||
autoSyncEnabled := app.Spec.SyncPolicy != nil && app.Spec.SyncPolicy.Automated != nil | |||
|
|||
addGauge(descAppInfo, 1, strconv.FormatBool(autoSyncEnabled), git.NormalizeGitURL(app.Spec.GetSource().RepoURL), app.Spec.Destination.Server, app.Spec.Destination.Namespace, string(syncStatus), string(healthStatus), operation) | |||
addGauge(descAppInfo, 1, strconv.FormatBool(autoSyncEnabled), git.NormalizeGitURL(app.Spec.GetSource().RepoURL), c.normalizeAppTargetRevision(app.Spec.GetSource().TargetRevision), app.Spec.Destination.Server, app.Spec.Destination.Namespace, string(syncStatus), string(healthStatus), operation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would the metric show if targetRevision
is not defined in the argocd Application?
You should add HEAD
in case targetRevision is not defined (as that's the default).
Displaying an empty string is misleading and most people likely won't have an explicit targetRevision
set, so they might be surprised.
For me as a user it would be VERY confusing to have master
, main
, develop
whitelisted by default, and then seeing an empty string for the label, when argocd actually syncs from main
. Setting it to HEAD
is less confusing, it's the default if targetRevision is not set, and matches existing docs: https://argo-cd.readthedocs.io/en/stable/user-guide/tracking_strategies/#head-branch-tracking
controller/metrics/metrics_test.go
Outdated
argocd_app_info{autosync_enabled="false",dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_status="Synced"} 1 | ||
argocd_app_info{autosync_enabled="true",dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app-2",namespace="argocd",operation="sync",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",sync_status="Synced"} 1 | ||
argocd_app_info{autosync_enabled="true",dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Degraded",name="my-app-3",namespace="argocd",operation="delete",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",revision="develop",sync_status="OutOfSync"} 1 | ||
argocd_app_info{autosync_enabled="false",dest_namespace="dummy-namespace",dest_server="https://localhost:6443",health_status="Healthy",name="my-app",namespace="argocd",operation="",project="important-project",repo="https://github.com/argoproj/argocd-example-apps",revision="",sync_status="Synced"} 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think showing an empty string here is misleading, and should show HEAD
instead.
Then at least we can say empty string means something that's both not whitelisted branch and not the default HEAD
branch.
Comparing my-app and my-app-4:
my-app the user didn't explicitly define a targetRevision, so it's really master
or main
or whatever the default branch is configured to. This should show HEAD
as the metric label.
my-app-4 the user didn't explicitly whitelist the custom branch name so the label is empty. This is fine.
hello @reegnz , thanks you for the feedbacks! I have edited the PR to handle "head" . |
controller/metrics/metrics.go
Outdated
@@ -363,6 +363,9 @@ func boolFloat64(b bool) float64 { | |||
} | |||
|
|||
func (c *appCollector) normalizeAppTargetRevision(in string) string { | |||
if len(in) == 0 { | |||
in = "head" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking, but git semantics seem to be using all caps HEAD
, not lowercase. lowercase head is probably nothing special for git (unless you have a branch called head
). At least that's what I'm seeing in all the docs and also ArgoCD UI, uppercase HEAD
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have hesitated, meanwhile it's good to have prom labels lowercased right?
cmd/argocd-application-controller/commands/argocd_application_controller.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Mikael Johansson <[email protected]> Signed-off-by: Thomas Decaux <[email protected]>
@ebuildy There were two variables with a typo:
You fixed the latter one, but there's references to them when the command flags are composed in the same file. That seems to be the reason for the failed builds on the latest commit! |
AFAICT still typos r( |
Well, this is here from 3 years now ^^ https://github.com/argoproj/argo-cd/pull/7374/files#diff-21d1e1ae7561765d523f51ae68a0b94580d1a5980378aa8ccbaa2a7581fc0643R52 , I could do another PR later to fix it with pleasure! |
Any updates on this? Would love to see this merged! |
AFAICT @ebuildy needs to sign off his commits because the DCO check is failing. |
Would love to see this PR get reviewed and merged. |
Add "targetRevision" for
argocd_app_info
metric.--> Should fix #4115
This is useful for: