一种选择是使用, 和filter的组合kubernetes
,如本例所示。nest
grep
您可以使用kubernetes
过滤器创建如下元数据:
{
"kubernetes": {
"pod_name": "myapp-0",
"namespace_name": "default",
"pod_id": "216cd7ae-1c7e-11e8-bb40-000c298df552",
"annotations": {
"please_log_with_parser": "myparser"
},
"host": "minikube",
"container_name": "myapp",
"docker_id": "370face382c7603fdd309d8c6aaaf434fd98b92421ce7c7c8aafe7697d4aa362"
}
}
然后使用nest
将注释提升到顶层。然后用于grep
丢弃仅在存在该注释时保留记录。
我的掌舵值现在看起来像这样:
rawConfig: |-
@INCLUDE fluent-bit-service.conf
@INCLUDE fluent-bit-input.conf
@INCLUDE fluent-bit-filter.conf
[FILTER]
Name nest
Match *
Operation lift
Nested_under kubernetes
Add_prefix kubernetes_
[FILTER]
Name nest
Match *
Operation lift
Nested_under kubernetes_annotations
Add_prefix kubernetes_annotations_
[FILTER]
Name grep
Match *
Regex kubernetes_annotations_fluentbit.io/parser .*
[FILTER]
Name nest
Match *
Operation nest
Wildcard kubernetes_annotations_*
Nest_under kubernetes_annotations
Remove_prefix kubernetes_annotations_
[FILTER]
Name nest
Match *
Operation nest
Wildcard kubernetes_*
Nest_under kubernetes
Remove_prefix kubernetes_
@INCLUDE fluent-bit-output.conf