Docker Filebeat 7.9.3 cannot collect metrics from http from outside the container

Hello Elastic Staff
I am not able to collect metrics from filebeat from the defined http port.
I can get the metrics from within the filebeat container with curl -XGET localhost:5066/stats.
When I want to collect the metrics from my machine I get the message "Empty reply from server". The container port is published to the host at port 5066.

My Configuration:

http.enabled: true
http.port: 5066

    path: ${path.config}/modules.d/*.yml
    reload.enabled: false

    - type: docker
      hints.enabled: true

- add_cloud_metadata: ~

  hosts: '${ELASTICSEARCH_HOSTS:elasticsearch:9200}'

Start filebeat by command:

docker run -p "5066:5066"   --name=filebeat   --user=root   --volume="$(pwd)/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml:ro"   --volume="/var/lib/docker/containers:/var/lib/docker/containers:ro"   --volume="/var/run/docker.sock:/var/run/docker.sock:ro" filebeat -e -strict.perms=false

Run curl -XGET http://localhost:5066/stats from my machine with the response: "curl: (52) Empty reply from server". Here I want to get the

Is there something missing that it won't work?



Can you try the curl command from inside the container to check that the endpoint is actually enabled?

Also maybe a redirection takes place so you could try adding some extra flags like -sS or -L.

Let me know if that helps.


thanks for your reply. I tried it from inside the container and got a response. So the endpoint should work.

I tried to run curl with the flags -sS and -L on my machine but the response is as before "Empty reply from server".


this is weird. Can you try with instead of localhost?

This also did not help. I now also set explicitly "0". But also no change of the result.

Ok I found the solution. I missed to set the variable to
Is this the expected behavior with the docker setup? Or should it be set by default to this value for docker containers?

It defaults to localhost so I guess localhost cannot be exposed for some docker-networking reason.

Yes I meant if it would be better for the elastic docker beat configs to default to instead of localhost. For the default in docker is already

Hmm, what exact files are you using? Where do you propose to apply this change?

I looked up the beats repository and couldn't find what I stated. I've read at some place in this forum that it is set for elastic docker containers by default. But sadly I cannot find the topic.
I think this topic is resolved. Thank you for your time and patience :slight_smile:

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