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

Add application name to appcontroller logs #18113

Closed
andrii-korotkov-verkada opened this issue May 7, 2024 · 8 comments
Closed

Add application name to appcontroller logs #18113

andrii-korotkov-verkada opened this issue May 7, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@andrii-korotkov-verkada
Copy link
Contributor

Summary

It would be great to have the application name mentioned in various logs of controller/appcontroller.go. Right now it's present in some, e.g. warning Failed to store cached manifests of previous revision for app '<app>': cache: key is missing, but is missing from many others, e.g. warning Skipping auto-sync: failed previous sync attempt to <hash>.

Motivation

The app controller has logs for all the apps, so a log without an app name makes it nearly impossible to do something about it. Having an app name mentioned in the logs would be a good step forward.

Proposal

Add the app name to the logs where it's missing in controller/appcontroller.go, at least for errors and warnings. A lot of methods in the app controller code already have an app object or app name as a parameter, so it shouldn't be a hard change.

@andrii-korotkov-verkada andrii-korotkov-verkada added the enhancement New feature or request label May 7, 2024
@andrii-korotkov-verkada andrii-korotkov-verkada changed the title Add application name to a appcontroller logs Add application name to appcontroller logs May 7, 2024
@crenshaw-dev
Copy link
Collaborator

I'd be very excited to see this PR.

@andrii-korotkov-verkada
Copy link
Contributor Author

Turns out the problem is more complicated than I thought. While some logs in appcontroller don't have info about the application, a lot of them include it in the structured data, including the example I've shown. However, when viewing the logs in the Datadog, application's fully qualified name is not available in the parsed event attributes and also not added to the log line (as it probably shouldn't). There's also been an example of logs where fields are added to the log message but in a way that indicate some broken parsing.

So the source of the issue lies in ArgoCD not using JSON format recommended by Datadog for integration, and the custom Grok parser for the ArgoCD logs we have seems to not cover some edge cases (probably / in the unquoted value of the field).

I'd open a discussion about potentially switching to JSON log format or finding other ways to have parsing working better.

@crenshaw-dev
Copy link
Collaborator

We should probably consider switching to JSON by default in 3.0. But the option is already available today.

@andrii-korotkov-verkada
Copy link
Contributor Author

Oh, my search for potential usage of JSONFormatter was too naive. After your pointer, I've traced that to util/log/logrus.go.

@andrii-korotkov-verkada
Copy link
Contributor Author

I'd just run the controller with the corresponding option, though still plan to submit the PR for some logging improvements.

andrii-korotkov-verkada added a commit to andrii-korotkov-verkada/argo-cd that referenced this issue May 12, 2024
Add application fully qualified name as a logrus field to several places that were missing it.
Remove appNamespace field and replace application name with a fully qualified name in a few places for consistency.
Add app project to the log fields.

Signed-off-by: Andrii Korotkov <137232734+andrii-korotkov-verkada@users.noreply.github.com>
andrii-korotkov-verkada added a commit to andrii-korotkov-verkada/argo-cd that referenced this issue May 12, 2024
Add application fully qualified name as a logrus field to several places that were missing it.
Remove appNamespace field and replace application name with a fully qualified name in a few places for consistency.
Add app project to the log fields.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
@andrii-korotkov-verkada
Copy link
Contributor Author

The PR is ready and passes CI. I'm not 100% sure though whether to log an app fully qualified name, or log a regular name and namespace separately. There's no consistency now - audit logger and couple of places choose the later, while multiple other places choose the former. In my PR I gave preference to the qualified name, but didn't go as far as editing audit logger. What do you think?

@andrii-korotkov-verkada
Copy link
Contributor Author

andrii-korotkov-verkada commented May 12, 2024

Thinking more about this, I'll probably switch to using a regular app name and have namespace as a separate parameter, as well as separate field for a qualified name. It's going to be reasonable when querying structured data via Datadog and also supporting just using grep on raw logs.

andrii-korotkov-verkada added a commit to andrii-korotkov-verkada/argo-cd that referenced this issue May 12, 2024
…ied name, add a common function for app log entry - Closes[argoproj#18113]

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
ishitasequeira pushed a commit that referenced this issue May 13, 2024
* chore: Improve appcontroller logs further - Closes [#18113]

Add application fully qualified name as a logrus field to several places that were missing it.
Remove appNamespace field and replace application name with a fully qualified name in a few places for consistency.
Add app project to the log fields.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* chore: Switch to using separate field for application name and qualified name, add a common function for app log entry - Closes[#18113]

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

---------

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
@andrii-korotkov-verkada
Copy link
Contributor Author

This should be in the next release.

mkieweg pushed a commit to mkieweg/argo-cd that referenced this issue Jun 11, 2024
…rgoproj#18174)

* chore: Improve appcontroller logs further - Closes [argoproj#18113]

Add application fully qualified name as a logrus field to several places that were missing it.
Remove appNamespace field and replace application name with a fully qualified name in a few places for consistency.
Add app project to the log fields.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* chore: Switch to using separate field for application name and qualified name, add a common function for app log entry - Closes[argoproj#18113]

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

---------

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this issue Jun 16, 2024
…rgoproj#18174)

* chore: Improve appcontroller logs further - Closes [argoproj#18113]

Add application fully qualified name as a logrus field to several places that were missing it.
Remove appNamespace field and replace application name with a fully qualified name in a few places for consistency.
Add app project to the log fields.

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

* chore: Switch to using separate field for application name and qualified name, add a common function for app log entry - Closes[argoproj#18113]

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>

---------

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
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

No branches or pull requests

2 participants