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

Inconsistent logging format #1191

Closed
emilbillberg opened this issue Dec 17, 2024 · 1 comment
Closed

Inconsistent logging format #1191

emilbillberg opened this issue Dec 17, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@emilbillberg
Copy link

Hi,

I am running victoria metrics operator v0.50.0; and I have noticed the log format can be a bit inconsistent.

I have noticed these log fields:

  • namespace
  • controller
  • desiredVersion
  • podMustRecreate
  • sts.name
  • vmcluster
  • vmalert
  • vmalertmanager
  • rules
  • secret_for
  • len
  • ' len ' (contains spaces)
  • 'map names'
  • 'invalid rules'
  • 'invalid configs'
  • 'desired version'

Some of them perhaps should stay, some of them should most likely be merged with the msg field instead. The spaces should also be removed from the keys as log collectors usually add a _ or . and it can be a bit weird.

I would expect msg, level and ts to exist as well as a few other consistent log fields which helps to understand the context of the log.

@f41gh7 f41gh7 added the bug Something isn't working label Dec 17, 2024
@f41gh7 f41gh7 self-assigned this Dec 17, 2024
f41gh7 added a commit that referenced this issue Dec 17, 2024
Current logger lig `logr` doesn't support formatted message field. Because of that
we had to use structured logging with key-value pairs. It has performance benefits.
But it also produces additional load into the logging systems. And the most importantly
it creats additional congnitive load on users. Since it's hard to join json fields
to get the context of the log message.

 This commit adds the following changes:
* use fmt.Sprintf in order to add more context to the message body.
* remove irrelevant fields from WithValues, like `secret_for` field
* change logger name to `controller.CRD_NAME` format.
* change child objects parent_NAME: OBJECT_NAMe to simple NAME: OBJECT_NAME. It allows to easily query
 log messages by pattern.

Related issue:
#1191

Signed-off-by: f41gh7 <[email protected]>
@f41gh7 f41gh7 added the waiting for release The change was merged to upstream, but wasn't released yet. label Dec 17, 2024
@f41gh7
Copy link
Collaborator

f41gh7 commented Dec 19, 2024

The issue was fixed at v0.51.1 release

It removes extra context from structured logs, like secret_for. And leaves only useful for filtering fields, such as:

  • component names: vmcluster, vmagent, etc...
  • controller.CRDName
  • namespace and parent_namespace

All previously added fields moved into message field value.

It'd be great to refactor logger later and use format string, instead of fmt.Sprintf workaround.

@f41gh7 f41gh7 closed this as completed Dec 19, 2024
@f41gh7 f41gh7 added waiting for release The change was merged to upstream, but wasn't released yet. and removed waiting for release The change was merged to upstream, but wasn't released yet. labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants