[英]How to pass a flag to klog for structured logging
As part of kubernetes 1.19, structured logging has been implemented.作为 kubernetes 1.19 的一部分, 结构化日志已经被实现。
I've read that kubernetes log's engine is klog
and structured logs are following this format :我读过kubernetes 日志的引擎是
klog
并且结构化日志遵循以下格式:
<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 !但更好的是,您显然可以将
--logging-format=json
标志传递给klog
以便直接在json
中生成日志!
{
"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.不幸的是,我一直无法找出我应该如何以及在哪里指定
--logging-format=json
标志。
Is it a kubectl
command?是
kubectl
命令吗? I'm using Azure's aks.我正在使用 Azure 的 aks。
--logging-format=json
is a flag which need to be set on all Kuberentes System Components ( Kubelet, API-Server, Controller-Manager & Scheduler). --logging-format=json
是一个需要在所有 Kuberentes 系统组件(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.不幸的是,您现在无法使用 AKS 完成此操作,因为您拥有来自 Microsoft 的托管控制平面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.