Is there support for selecting containers other than by container id?

docker
(David) #1

I want to apply a prospector to only some of the docker containers I am running. However, it appears that the only way to select the containers in the prospector yml config is to specify container.ids which only matches on the container id. What would be really helpful is to match on either container name or a label on the docker image. Is there any way to do this currently? If not, is there any planned support for this?

(Shaunak Kashyap) #2

Yes, it's possible to specify matching conditions for fields other than container IDs. This doc gives you an idea of how to do that: https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html.

(Tiago Silva) #3

Hello Shaunak,
My use case is that I have 3 containers in the server and I have to collect logs using FIleBeat from only a specific one.
I cannot use container ID because this container can change so my idea was to do it by container name (that would be the same all the time).

My configuration bellow does not send any logs to elastic.
The autodiscover configuration can be used without filebeat docker input?

(The documentation is not very clear on this)


filebeat.autodiscover:

providers:
- type: docker
templates:
- condition:
contains:
docker.container.name: SPECIFIC_CONTAINER
config:
- type: log
paths:
- /var/lib/docker/containers/${data.docker.container.id}/*.log

(Tiago Silva) #4

Another similar post is this one: Problem getting autodiscover docker to work with filebeat

In the last reply states the same doubt i am having, how to use filebeat input together with autodiscover, and then filter only a specific container with certain name and new ones appearing with the same container image.

(This would be helpfull also because there are containers like filebeat that i dont want to get inputs from),

(system) closed #5

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