简体   繁体   中英

How to pass a flag to klog for structured logging

As part of kubernetes 1.19, structured logging has been implemented.

I've read that kubernetes log's engine is klog and structured logs are following this format :

<klog header> "<message>" <key1>="<value1>" <key2>="<value2>" ...

Cool ! But even better, you apparently can pass a --logging-format=json flag to klog so logs are generated in json directly !

{
   "ts": 1580306777.04728,
   "v": 4,
   "msg": "Pod status updated",
   "pod":{
      "name": "nginx-1",
      "namespace": "default"
   },
   "status": "ready"
}

Unfortunately, I haven't been able to find out how and where I should specify that --logging-format=json flag.

Is it a kubectl command? I'm using Azure's aks.

--logging-format=json is a flag which need to be set on all Kuberentes System Components ( Kubelet, API-Server, Controller-Manager & Scheduler). You can check all flags here .

Unfortunately you cant do it right now with AKS as you have the managed control plane from Microsoft.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM