# Filebeat with custom logfile and kubernetes metadata to elasticsearch and kibana

**URL:** https://discuss.elastic.co/t/filebeat-with-custom-logfile-and-kubernetes-metadata-to-elasticsearch-and-kibana/299403
**Category:** Beats
**Tags:** filebeat
**Created:** [March 11, 2022, 6:40am UTC](https://discuss.elastic.co/t/filebeat-with-custom-logfile-and-kubernetes-metadata-to-elasticsearch-and-kibana/299403 "2022-03-11T06:40:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![v\_anil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/v_anil/32/79783_2.png) [@v\_anil](https://discuss.elastic.co/u/v_anil)
#### Post date: [March 11, 2022, 6:40am UTC](https://discuss.elastic.co/t/filebeat-with-custom-logfile-and-kubernetes-metadata-to-elasticsearch-and-kibana/299403/1 "2022-03-11T06:40:08Z")

</div>

Our applications are deployed in AWS EKS cluster, and for certain reasons we need to write our app logs to separate file lets say ${POD\_NAME}.applog instead of stdout (we mounted /var/log/container/ to the pod /log folder and app writes /log/${POD\_NAME}.applog ). And we are using filebeat to send the logs to Elasticsearch and we are using Kibana for visualization. Our filebeat config file looks like this

```auto
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: log
      paths:
        - /var/log/containers/*.applog
      json.keys_under_root: true
      json.message_key: log
      processors:
        - add_cloud_metadata:
        - add_host_metadata:

```

This is working fine, but we realised we are missing the kuberenetes metadata in ES and Kibana. But we are getting kuberenetes metadata when we include `-type: conatainer` .

```auto
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: log
      paths:
        - /var/log/containers/*.applog
      json.keys_under_root: true
      json.message_key: log
    - type: container
      paths:
        - /var/log/containers/*.log
      processors:
        - add_kubernetes_metadata:
            host: ${NODE_NAME}
            matchers:
            - logs_path:
                logs_path: "/var/log/containers/"

```

So we tried adding the config like this

```auto
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: log
      paths:
        - /var/log/containers/*.applog
      json.keys_under_root: true
      json.message_key: log
      processors:
        - add_kubernetes_metadata:
            in_cluster: true
            host: ${NODE_NAME}
        - add_cloud_metadata:
        - add_host_metadata:

```

Still we are not getting the kuberenetes metadata in kibana. I tried with all trial and error method, but nothing works.

Can someone please help me how to get Kubernetes metadata with custom logfile in filebeat.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 8, 2022, 6:40am UTC](https://discuss.elastic.co/t/filebeat-with-custom-logfile-and-kubernetes-metadata-to-elasticsearch-and-kibana/299403/2 "2022-04-08T06:40:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
