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

Exposing Application labels in events #11381

Open
mrysavy opened this issue Nov 21, 2022 · 9 comments · May be fixed by #18160
Open

Exposing Application labels in events #11381

mrysavy opened this issue Nov 21, 2022 · 9 comments · May be fixed by #18160
Labels
enhancement New feature or request

Comments

@mrysavy
Copy link

mrysavy commented Nov 21, 2022

Summary

I would like to have Application labels also in argo-cd events, the same way as it is possible to have them in Prometheus metrics (see https://argo-cd.readthedocs.io/en/stable/operator-manual/metrics/#exposing-application-labels-as-prometheus-metrics)

Motivation

Our use-case is almost the same as the one stated in the documentation for Exposing Application labels as Prometheus metrics.
We have several Application labels which differentiate team (business application) and environment (dev/test/prod) and we would like to forward ArgoCD Application events (as well as container stdout) to central ELK, particular index.
Unfortunately we don't have strict naming convention for Kubernetes namespaces or ArgoCD application which we could use for the corrent messages distribution.

Proposal

The implementation should be similar to the implementation for Prometheus metrics - specify application labels for events and use them in event.metadata.anotations (like dest-namespace and dest-server here and here).

Finaly I would like to ask if there is some workaround that can we use now.

Thanks

@mrysavy mrysavy added the enhancement New feature or request label Nov 21, 2022
@mrysavy
Copy link
Author

mrysavy commented Feb 13, 2023

I would like to extend this proposal. Sometimes using Application labels may not be enough, because important labels are on the AppProject only (our another case). So I propose to allow to expose particular labels from AppProject as well.

And it would be great to enable this for prometheus metrics as well.

@jannfis
Copy link
Member

jannfis commented Mar 1, 2023

I think this would be useful. However, I have a slight concern about using both, labels from Application and AppProject here.

If both, Application and AppProject have a label with the same name, but a different value, how would we decide which one will end up on the event? Making this configurable would considerably increase the effort to be put into the change for little value add. I'd prefer it to be a one-size-fits-all solution, i.e. to just copy all labels from the Application over to the Event, minus the ones that are already defined (dest-namespace and dest-server).

@mrysavy
Copy link
Author

mrysavy commented Mar 6, 2023

I have several ideas:

  • specify both AppProject labels and AppProject labels (enabled for storing in events) as different application-controller arguments ("events-application-labels" and "events-appproject-labels" for example) and fail start when both arguments contain same label
    • and similarly for metrics - metrics-application-labels / metrics-appproject-labels
  • prioritize Application before AppProject and have only one argument for both labels (more precisly one argument for both Application and AppProject for event and another one for both Application and AppProject for metrics), so when Application and AppProject both of them have values for the same label - Application wins
    • so first get labels from AppProject and then get labels from Application (with override)

I prefer second variant ("prioritize Application before AppProject") - almost the same as you said. But I'm not sure if you count with argument for selecting labels for propagating to events. I count with it, because propagating labels to metrics is based on it.

There is also possibility to have only one argument for all combination Application/AppProject, metrics/events (and not different for metrics and events as I stated above). It doesn't matter in our case.

@jannfis
Copy link
Member

jannfis commented Mar 8, 2023

As long as this behaviour is documented, I'd be fine with labels on the Application to override labels from the AppProject on the emitted events.

@jannfis
Copy link
Member

jannfis commented Mar 8, 2023

I was wondering though, what ends up on the events should be annotations, not labels, right?

@mrysavy
Copy link
Author

mrysavy commented Mar 9, 2023

We count with labels.
Also current implementation of metrics exposing counts with labels (see https://argo-cd.readthedocs.io/en/stable/operator-manual/metrics/#exposing-application-labels-as-prometheus-metrics).

@svghadi
Copy link
Contributor

svghadi commented Apr 26, 2024

I am working on implementing this feature and was thinking, would it make sense to have all the app & proj labels added by default without making it configurable. We already have lot of configurable params in Argo CD and making this configurable will introduce 2 more flags in app-controller and argocd-server.
Although, I believe adding all the labels in events may not have a significant impact on performance/storage/security, I am not sure on other potential consequences.

@svghadi svghadi linked a pull request May 10, 2024 that will close this issue
14 tasks
@svghadi
Copy link
Contributor

svghadi commented May 10, 2024

Hi @mrysavy , @jannfis, I have a PR (#18160) up to implement this enhancement. I have introduced a new key in argocd-cm instead of cli flags. Configmap approach made more sense to me as we could eliminate the need of updating flag configurations in 2 places i.e app-controller and argocd-server. PTAL. Thanks.

@michalrysavy-ext95730
Copy link

Hi @svghadi, I've tried the patch and it looks good. Thanks for the implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants