-
Notifications
You must be signed in to change notification settings - Fork 1.4k
📖 Update logging guidelines #13011
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
📖 Update logging guidelines #13011
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ In Cluster API we strive to follow three principles while implementing logging: | |
| Kubernetes defines a set of [logging conventions](https://git.k8s.io/community/contributors/devel/sig-instrumentation/logging.md), | ||
| as well as tools and libraries for logging. | ||
|
|
||
| Cluster API should align to those guidelines and use those tools as much as possible. | ||
|
|
||
| ## Continuous improvement | ||
|
|
||
| The foundational items of Cluster API logging are: | ||
|
|
@@ -100,6 +102,11 @@ key value pairs (in order of importance): | |
| creates a MachineSet. | ||
| - Other Key value pairs. | ||
|
|
||
| Notably, over time in CAPI we are also standardizing usage of other key value pairs to improve consistency when reading | ||
| logs, e.g. | ||
| - key `reason` MUST be used when adding details about WHY a change happened. | ||
| - key `diff` MUST be used when documenting the diff in an object that either lead to a chance, or that is resulting from a change. | ||
sbueringer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Log Messages | ||
|
|
||
| - A Message MUST always start with a capital letter. | ||
|
|
@@ -108,7 +115,13 @@ key value pairs (in order of importance): | |
| the action log and the corresponding error log; While logging before the action, log verbs should use the -ing form. | ||
| - Ideally log messages should surface a different level of detail according to the target log level (see [log levels](#log-levels) | ||
| for more details). | ||
| - If Kubernetes resource name is used in log messages, it should be used as is, For example `Reconciling DockerMachineTemplate` | ||
| - If Kubernetes resource name is used in log messages, it MUST be used as is, For example `Reconciling DockerMachineTemplate` | ||
| - If an API field name is used in log messages, the entire path MUST be used and field names MUST capitalized like in the | ||
| API (not as in the golang type). For example `Waiting for spec.providerID to be set` | ||
| - If a log messages about a controlled or a referenced object, e.g. Machine controller performing an action on MachineSet, | ||
sbueringer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| the message MUST contain the Kind of the controlled/referenced object and its name, for example `Created MachineSet foo-bar` | ||
| - If the controlled/referenced object is in another namespace, use namespace/name instead of name | ||
|
Comment on lines
+122
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure to repeat the object name, which should already be a structured field? I'm not against this repetition to make it more readable for humans – just asking if this was considered. The namespace should be in the structured field automatically (via
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should repeat it. My experience is that omitting it makes it unnecessarily hard to figure out what's going on, e.g. Created Machine Created Machine machine-1 With tools like Grafana/Kibana etc. it makes sense in my opinion to only show specific parts of the log, E.g. to only show controller-name + msg. If all the k/v pairs have to be shown for the log to make sense the view becomes extremely verbose
I think we don't need a util for that. I'm not aware of a single case of this in core Cluster API. We just use |
||
| - The controlled/referenced MUST also be added as a key value pair (see guidelines above) | ||
sbueringer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Log Levels | ||
|
|
||
|
|
||
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 would be very helpful. Can we specify a suggested format? For example, subfields
old/new, or string format (less helpful)?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 it's extremely hard to standardize as we have a lot of different cases where we have different data that we can use
(check the usages of the "diff" key today in CAPI)