Small fixes in structured logging post
* Fix name of namespace to kube-system * Change kubedns to coredns * Remove tailing whitespaces * Fix names of json keys (should be lowerCamelCase) * Fix quotation mark (fixes broken json highlighting)pull/23698/head
parent
377ca1f44f
commit
e2f152a867
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
layout: blog
|
layout: blog
|
||||||
title: 'Introducing Structured Logs'
|
title: 'Introducing Structured Logs'
|
||||||
date: 2020-09-04
|
date: 2020-09-04
|
||||||
slug: kubernetes-1-19-Introducing-Structured-Logs
|
slug: kubernetes-1-19-Introducing-Structured-Logs
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ To maintain backwards compatibility, structured logs will still be outputted as
|
||||||
We've added two new methods to the klog library: InfoS and ErrorS. For example, this invocation of InfoS:
|
We've added two new methods to the klog library: InfoS and ErrorS. For example, this invocation of InfoS:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
klog.InfoS(“Pod status updated”, “pod”, klog.KObj(pod), “status”, status)
|
klog.InfoS("Pod status updated", "pod", klog.KObj(pod), "status", status)
|
||||||
```
|
```
|
||||||
|
|
||||||
will result in this log:
|
will result in this log:
|
||||||
|
|
||||||
```
|
```
|
||||||
I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kube-system/kubedns" status=”ready”
|
I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kube-system/kubedns" status="ready"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, if the --logging-format=json flag is set, it will result in this output:
|
Or, if the --logging-format=json flag is set, it will result in this output:
|
||||||
|
@ -33,11 +33,11 @@ Or, if the --logging-format=json flag is set, it will result in this output:
|
||||||
{
|
{
|
||||||
"ts": 1580306777.04728,
|
"ts": 1580306777.04728,
|
||||||
"msg": "Pod status updated",
|
"msg": "Pod status updated",
|
||||||
"Pod”: {
|
"pod": {
|
||||||
“Name”: “kubedns”,
|
"name": "coredns",
|
||||||
“Namespace”: “kubedns”
|
"namespace": "kube-system"
|
||||||
},
|
},
|
||||||
“status”: “ready”
|
"status": "ready"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue