kubernetes容器\u名称在fluentdconfiguration中为null
我尝试从我的应用程序容器中获取日志,并将fluentd日志代理附加为我的项目中的sidecar容器。我想在我的Kibana仪表板中获取哪个日志来自哪个应用程序。这就是为什么我在fluentd中这样配置kubernetes容器\u名称在fluentdconfiguration中为null,kubernetes,fluentd,efk,Kubernetes,Fluentd,Efk,我尝试从我的应用程序容器中获取日志,并将fluentd日志代理附加为我的项目中的sidecar容器。我想在我的Kibana仪表板中获取哪个日志来自哪个应用程序。这就是为什么我在fluentd中这样配置 <source> @id fluentd-containers.log @type tail path /var/log/containers/mylog*.log pos_file /var/log/es-containers.log.pos time_forma
<source>
@id fluentd-containers.log
@type tail
path /var/log/containers/mylog*.log
pos_file /var/log/es-containers.log.pos
time_format %Y-%m-%dT%H:%M:%S.%NZ
tag kubernetes.myapp.container
read_from_head true
<parse>
@type none
</parse>
</source>
<filter kubernetes**>
@type record_transformer
enable_ruby true
<record>
service_name ${tag_parts[1]}
instance_name ${record["kubernetes"]["container_name"]}
log_type ${tag_parts[2]}
host_name ${hostname}
send_to "ES"
</record>
</filter>
<match kubernetes.**>
@type stdout
</match>
@id fluentd-containers.log
@型尾
路径/var/log/containers/mylog*.log
pos_文件/var/log/es-containers.log.pos
时间\u格式%Y-%m-%dT%H:%m:%S.%NZ
标记kubernetes.myapp.container
从你的头上读出来是真的
@无类型
@型记录变压器
启用\u ruby true
服务名称${tag\u parts[1]}
实例_name${record[“kubernetes”][“container_name”]}
日志类型${tag\u parts[2]}
主机名${hostname}
将_发送到“ES”
@类型标准输出
但是当我部署它时,${[record[“”][“container\u name”]}
在显示未知占位符${record[“kubernetes”][“container\u name”]}
时变为空。请帮助我如何解决它,谢谢
收到那个错误信息了吗
0转储错误事件:错误\u class=RuntimeError=“未能
展开记录[\'kubernetes\'][\'container\u name\']
:错误=
nil:NilClass“location=“/fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.11.2/lib/fluent/plugin/filter\u record\u transformer.rb:310:inrescue in expand'”tag=“kubernetes.myapp.container”time=2020-09-23
11:29:05.705209241+0000记录={“消息”=>“{”日志“:“I0923
11:28:59.157177 1 main.开始:71]健康检查
成功\n,“流”:“标准”,“时间”:“2020-09-23T11:28:59.157256887Z”}
`记录
不包含您要访问的必填字段,即记录[“kubernetes”][“container_name”]
您需要确保它具有这些字段
请浏览并插入此插件以获取详细信息。您正在使用吗?在记录之前似乎有一个额外的[
。
@Azeem不,我没有。我需要使用它吗?@mdaniel即使我删除了额外的[
,也会收到以下错误消息转储错误事件:error\u class=RuntimeError error=“无法展开
record[\“kubernetes\”[\“container\u name\”]``@PPShein:请浏览容器部署文章:。