'Logstash cannot connect to Elasticsearch on kubernetes

I'm having trouble connecting Logstash to Elasticsearch.

I have installed ELK stack on kubernetes using helm. Every pod is running and is in ready state. Elasticsearch and kibana are perfectly fine (i.e connecting properly). The problem is with logstash not able to identify Elasticsearch to establish connection.

Find the screenshot of error below:

here's the problem

as you can see everything is running fine

Please help to suggest proper solution for the same.



Solution 1:[1]

Look at the following https://medium.com/kubernetes-tutorials/exporting-kubernetes-logs-to-elasticsearch-using-fluent-bit-758e8de606af

In step 3, the fluentbit DaemonSet is deployed. Here, the env variable FLUENT_ELASTICSEARCH_HOST is modified to elasticsearch.default.svc.cluster.local according to https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#srv-records in the format of [srv].[namespace].srv.cluster.local. That connection string is known by the Kubernetes DNS.

So change your environment variable to the 'Kubernetes DNS' format

By following the ECK tutorial, you should have a service already, which you can get by executing kubectl get services -n [namespace] or kubectl get services -A

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1