yes, file beat collect logs from Hostpath which is kubernetes emptyDir mount point
inner pod path:
/home/sclogs/logs/applogs/myapp/tomcat_stdout.log
Host path:
/var/lib/kubelet/pods/*/volumes/kubernetes.io~empty-dir/logs/applogs/*/tomcat_stdout.log
I have try
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/lib/kubelet/pods/*/volumes/kubernetes.io~empty-dir/logs/applogs/*/tomcat_stdout.log
processors:
- add_kubernetes_metadata:
host: ${NODE_NAME}
default_indexers.enabled: false
default_matchers.enabled: false
indexers:
- pod_uid:
matchers:
- logs_path:
logs_path: '/var/lib/kubelet/pods'
resource_type: 'pod'
output.console:
pretty: true
console output:
{
"@timestamp": "2021-04-01T12:21:03.795Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "7.12.0"
},
"message": "here is application stdout message",
"input": {
"type": "log"
},
"kubernetes": {
"labels": {
"app": "workapp",
"pod-template-hash": "645bc8fb7b",
"szone": "sc"
},
"node": {
"name": "node.172.28.131.146",
"uid": "5f187da8-4650-4fcc-b4ea-61dccfc1410a",
"labels": {
"kubernetes_io/os": "linux",
"beta_kubernetes_io/arch": "amd64",
"beta_kubernetes_io/os": "linux"
},
"hostname": "node.172.28.131.146"
},
"namespace_uid": "da7ac4c7-f733-4728-988e-7a5ba6e2dedc",
"pod": {
"name": "workapp-645bc8fb7b-qqf5p",
"uid": "961e07e0-11b3-40c8-92ea-0be804d5d949"
},
"namespace": "sc",
"replicaset": {
"name": "workapp-645bc8fb7b"
}
},
"ecs": {
"version": "1.8.0"
},
"host": {
"name": "filebeat-new-6d87884ccf-whszl"
},
"agent": {
"hostname": "filebeat-new-6d87884ccf-whszl",
"ephemeral_id": "f9bf1229-039b-4921-b4ea-933133286903",
"id": "d8fcd0ac-5522-4319-9425-289bb5ddf13d",
"name": "filebeat-new-6d87884ccf-whszl",
"type": "filebeat",
"version": "7.12.0"
},
"log": {
"offset": 1944254,
"file": {
"path": "/var/lib/kubelet/pods/961e07e0-11b3-40c8-92ea-0be804d5d949/volumes/kubernetes.io~empty-dir/logs/applogs/worknum/tomcat_stdout.log"
}
}
}
more filed get ,but still no podip
I have try autodicover, but it get "Non-zero metric"
filebeat.autodiscover:
providers:
- type: kubernetes
templates:
- condition:
contains:
kubernetes.pod.name: tomcat
config:
- type: log
paths:
- /var/lib/kubelet/pods/${kubernetes.pod.uid}*/volumes/kubernetes.io~empty-dir/logs/applogs/*/tomcat_stdout.log
output.console:
pretty: true