# Filebeat: read file inside container

**URL:** <https://discuss.elastic.co/t/filebeat-read-file-inside-container/160528>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 12, 2018, 11:32am UTC](https://discuss.elastic.co/t/filebeat-read-file-inside-container/160528 "2018-12-12T11:32:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranay\_sankpal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranay_sankpal/32/44084_2.png) [@pranay\_sankpal](https://discuss.elastic.co/u/pranay_sankpal)\
**Post date:** [December 12, 2018, 11:32am UTC](https://discuss.elastic.co/t/filebeat-read-file-inside-container/160528/1 "2018-12-12T11:32:39Z")

</div>

Hi,

We are setting up logging for services running on kubernetes. These services generates logs file in the APP\_DIR inside a container. How can I ship these logs to ES?

I've refered :  
[https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html)

Deployed filebeat as :

> <https://github.com/elastic/beats/blob/master/deploy/kubernetes/filebeat-kubernetes.yaml>

my filebeat configmap :

```auto
kind: ConfigMap
metadata:
  name: filebeat-config
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    setup.dashboards.enabled: true
    setup.template.enabled: true

    setup.template.settings:
      index.number_of_shards: 1

    filebeat.autodiscover:
      providers:
        - type: kubernetes
          templates:
            - condition.contains:
                kubernetes.container.image: my_app
              config:
                - type: my_app-logs
                  paths:
                    - "/var/www/my_app/app.log"
    processors:
      - add_cloud_metadata:
    cloud.id: ${ELASTIC_CLOUD_ID}
    cloud.auth: ${ELASTIC_CLOUD_AUTH}
    output.elasticsearch:
      hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
      username: ${ELASTICSEARCH_USERNAME}
      password: ${ELASTICSEARCH_PASSWORD}

```

Is it possible to read files inside container using filebeat-daemonset deployment?

Is above approach correct?

Some direction would be helpful.

---

<div class="post-metadata">

**Author:** ![pappaola](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@pappaola](https://discuss.elastic.co/u/pappaola)\
**Post date:** [December 13, 2018, 1:32pm UTC](https://discuss.elastic.co/t/filebeat-read-file-inside-container/160528/2 "2018-12-13T13:32:57Z")

</div>

I never used kubernetes that much, but it's like Docker, right. So maybe something like this:  
[https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/](https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/)

A shared volume would be my best bet.

---

<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:** [January 10, 2019, 1:32pm UTC](https://discuss.elastic.co/t/filebeat-read-file-inside-container/160528/3 "2019-01-10T13:32:58Z")

</div>

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