Add kubernetes metadata to fluentd/fluent bit sidecar

<filter kubernetes.var.log.containers.**.log>
@type kubernetes_metadata
</filter>
- name: fluentd-sidecar
image: ..../fluentd...
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_LABELS
valueFrom:
fieldRef:
fieldPath: metadata.labels['app']
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
<filter kubernetes.** >
@type record_transformer
<record>
NODE_NAME "#{ENV['NODE_NAME']}"
</record>
<record>
POD_NAMESPACE "#{ENV['POD_NAMESPACE']}"
</record>
<record>
POD_NAME "#{ENV['POD_NAME']}"
</record>
</filter>
[FILTER]
Name modify
Match *
Add POD_NAME ${POD_NAME}
Add POD_NAMESPACE ${POD_NAMESPACE}
Add NODE_NAME ${NODE_NAME}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store