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
Added support for JSON based logging #11133
Conversation
Commit 3de339d71371ce8a7714b2f9c59686e67a5697ff does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
Please set the appropriate release note label. |
Please set the appropriate release note label. |
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.
Thanks for the contribution! I have a couple of minor comments below on the code.
Signed-off-by: Maxime VISONNEAU <maxime.visonneau@gmail.com>
switch os.Getenv("INITSYSTEM") { | ||
case "SYSTEMD": | ||
fileFormat.FullTimestamp = true | ||
default: | ||
fileFormat.TimestampFormat = time.RFC3339 |
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's the rational behind this removal?
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.
my former comment on this got removed, my bad. I assumed this statement was not actually used given that the logrus.Formatter
is configured with an hardcoded value for disabling the timestamp 🤔 DisableTimestamp = true
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.
Well that explains stuff... and I thought it was because of the detection of os.Getenv("INITSYSTEM")
. @borkmann you usually run cilium-agent standalone. Did you ever miss the lack of timestamps?
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.
Nope, not yet so far. ;)
switch os.Getenv("INITSYSTEM") { | ||
case "SYSTEMD": | ||
fileFormat.FullTimestamp = true | ||
default: | ||
fileFormat.TimestampFormat = time.RFC3339 |
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.
Well that explains stuff... and I thought it was because of the detection of os.Getenv("INITSYSTEM")
. @borkmann you usually run cilium-agent standalone. Did you ever miss the lack of timestamps?
test-me-please |
This PR enable support for getting JSON based logs out of the binaries.
It can be set using either
or
--log-opt format=json
There is a slight issue related to some log lines that get written before the logger gets actually configured. I reckon it must also be the case when log-driver is set to syslog or the level is different than the default though.