Kubernetes Contributor Summit 2023: A Reunion in Shanghai
On September 26, 2023, nearly 50 contributors gathered for the Kubernetes Contributor Summit in …
The Working Group for Structured Logging has introduced new features to the logging infrastructure in Kubernetes 1.24. In this article, you’ll learn how developers can leverage these to make log outputs more useful and how they can actively participate in improving Kubernetes.
The goal of structured logging is to replace C-style formatting and the resulting opaque log strings with log entries that have a clearly defined syntax for separately storing messages and parameters, for instance, as a JSON structure.
When using the traditional klog text output format for structured log calls, strings were originally output with \n escape sequences, unless they were embedded in a structure. For structures, log entries could still span multiple lines, with no clean way to split the log stream into individual entries:
I1112 14:06:35.783529 328441 structured_logging.go:51] “using InfoS” longData={Name:long Data:Multiple lines with quite a bit of text. internal:0} I1112 14:06:35.783549 328441 structured_logging.go:52] “using InfoS with\nthe message across multiple lines” int=1 stringData=“long: Multiple\nlines\nwith quite a bit\nof text.” str=“another value”
Now, the < and > markers are used along with indentation to ensure that splitting at a klog header at the beginning of a line is reliable and the resulting output is human-readable:
I1126 10:31:50.378204 121736 structured_logging.go:59] “using InfoS” longData=< {Name:long Data:Multiple lines with quite a bit of text. internal:0}
I1126 10:31:50.378228 121736 structured_logging.go:60] “using InfoS with\nthe message across multiple lines” int=1 stringData=< long: Multiple lines with quite a bit of text.
str=“another value”
Note that the log message itself is output with quotes. It should be a fixed string identifying a log entry, so line breaks should be avoided there.
Before Kubernetes 1.24, some log calls in the kube-scheduler still used klog.Info for multiline strings to avoid unreadable output. Now, all log calls have been updated to support structured logging.
The new structured logging features in Kubernetes 1.24 provide developers and DevOps teams with the opportunity to significantly enhance the quality of their logs. Use these changes to better monitor your applications and identify issues more quickly. ayedo is happy to support you as a partner in implementing Kubernetes solutions!
Source: Kubernetes Blog
On September 26, 2023, nearly 50 contributors gathered for the Kubernetes Contributor Summit in …
Kubernetes 1.21 introduces the first officially supported stable metrics with the completion of the …
Kubernetes v1.26 introduces an exciting new feature: the general availability (GA) of Kubelet …