# Collect logs for specific containers or namespace in Openshift/Kubernetes

**URL:** <https://discuss.elastic.co/t/collect-logs-for-specific-containers-or-namespace-in-openshift-kubernetes/232417>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [May 13, 2020, 10:39am UTC](https://discuss.elastic.co/t/collect-logs-for-specific-containers-or-namespace-in-openshift-kubernetes/232417 "2020-05-13T10:39:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [May 14, 2020, 7:12pm UTC](https://discuss.elastic.co/t/collect-logs-for-specific-containers-or-namespace-in-openshift-kubernetes/232417/2 "2020-05-14T19:12:29Z")

</div>

Hey @sayeedc,

Yes, you can use hints-based autodiscover to provide a different configuration per pod or namespace. Hints are defined as annotations in your kubernetes resources.

In the main configuration file you would need this setup:

```auto
filebeat.autodiscover:
  providers:
    - type: kubernetes
      hints.enabled: true
      add_resource_metadata.namespace.enabled: true
      hints.default_config.enabled: false

```

This tells the autodiscover provider to enable hints, to take into account namespace metadata, and as default configuration for each pod, it disables the inputs.

Then you can add configurations per namespace, or per pod. Adding an annotation like the following one will enable the inputs selectively:

```auto
annotations:
  co.elastic.logs/enabled: 'true'

```

If you do it in a pod, its logs will be collected. If you do it in a namespace, the logs of all the pods in this namespace will be collected.

You can see in the documentation other settings you can use per pod or namespace, apart of `co.elastic.logs/enabled`: [https://www.elastic.co/guide/en/beats/filebeat/7.7/configuration-autodiscover-hints.html](https://www.elastic.co/guide/en/beats/filebeat/7.7/configuration-autodiscover-hints.html)

---

_[View the full topic](https://discuss.elastic.co/t/collect-logs-for-specific-containers-or-namespace-in-openshift-kubernetes/232417)._
