Metricbeat failed to connect with elasticsearch

[root@scw-elated-franklin ~]# sudo metricbeat test output
elasticsearch: http://51.77.:9200...
parse url... OK
connection...
parse host... OK
dns lookup... OK
addresses: 51.77..
dial up... ERROR dial tcp 51.77.:9200: connect: connection refused

Hi @zmira_meriem,

Did you check if you can connect to your 51.77... instance on the port 9200 from your scw-elated-franklin istance?

Look like it's a network problem. Can you share the result of a
curl -XGET 51.77....:9200

if it's work it will return a json result with the elastic version information.

1 Like

tnx for your reply @gabriel_tessier
that result for this cmd:
[root@scw-elated-franklin ~]# curl -XGET 51.77..:9200
curl: (7) Failed connect to 51.77..:9200; Connection refused
[root@scw-elated-franklin ~]#

So it's a network problem need to check on your 51.77 server that elastic is correctly running and thre's no firewall blocking the access.

@gabriel_tessier elasticsearch is starting
[root@vps705402 ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: active (running) since jeu. 2019-07-04 16:27:23 CEST; 1h 9min ago
Docs: http://www.elastic.co
Main PID: 21492 (java)
CGroup: /system.slice/elasticsearch.service
├─21492 /usr/share/elasticsearch/jdk/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative...
└─21570 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

juil. 04 16:27:23 vps705402.ovh.net systemd[1]: Stopped Elasticsearch.
juil. 04 16:27:23 vps705402.ovh.net systemd[1]: Started Elasticsearch.
juil. 04 16:27:24 vps705402.ovh.net elasticsearch[21492]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[root@vps705402 ~]#

@gabriel_tessier

the netsat cmd show that:

[root@vps705402 ~]# netstat -ntlp
Connexions Internet actives (seulement serveurs)
Proto Recv-Q Send-Q Adresse locale Adresse distante Etat PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3416/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3361/master
tcp 0 0 0.0.0.0:5601 0.0.0.0:* LISTEN 21581/node
tcp6 0 0 127.0.0.1:9200 :::* LISTEN 21492/java
tcp6 0 0 127.0.0.1:9300 :::* LISTEN 21492/java
tcp6 0 0 :::22 :::* LISTEN 3416/sshd
[root@vps705402 ~]#

If elastic is running it's ok what about firewall rules?
you can maybe get the list of your open port with iptables -L

@gabriel_tessier
this is the open ports:

[root@vps705402 ~]# sudo firewall-cmd --list-ports
9200/tcp 5601/tcp
[root@vps705402 ~]#

If the firewall allow you to connect but curl is not working my guess is that something else and it's sound like a hosting problem.
As elastic is correctly running but you can't access it from the scw-elated-franklin instance.

You may have more chance to figure out the ovh network configuration on developpez.net forum. :grinning:

Bonne continuation.

It looks like your instance is configured to just bind to local host. Can you post your Elasticsearch config?

1 Like

@Christian_Dahlqvist thnx for u r reply
this a elastic search configuration:

Make sure that the heap size is set to about half the memory available

on the system and that the owner of the process is allowed to use this

limit.

Elasticsearch performs poorly when the system is swapping the memory.

---------------------------------- Network -----------------------------------

Set the bind address to a specific IP (IPv4 or IPv6):

network.host: localhost

Set a custom port for HTTP:

http.port: 9200

For more information, consult the network module documentation.

--------------------------------- Discovery ---

it is just listning to localhost

Preformatted text[root@vps705402 kibana]# netstat -anp|grep 9200
tcp 0 0 127.0.0.1:49890 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49912 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49892 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49918 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49920 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49922 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49908 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49886 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49884 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49928 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49916 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49914 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49896 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49910 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49906 127.0.0.1:9200 ESTABLISHED 17398/node
tcp 0 0 127.0.0.1:49926 127.0.0.1:9200 ESTABLISHED

Sorry I mess it @Christian_Dahlqvist found it !!

You need to set
network.host: [_eth0_, _local_]

Also don't forget to restrict access to your elastic server only for the metricbeat instance.

indent preformatted text by 4 spaces

@gabriel_tessier i change it like u say but the elasticsearch failed to starting

Set the bind address to a specific IP (IPv4 or IPv6):

network.host: [_eth0_, _local_]

Set a custom port for HTTP:

http.port: 9200

For more information, consult the network module documentation.

--------------------------------- Discovery -------------------Preformatted text

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

1 Like

Sorry, I copy the value from my file as example you'd better to check the documentation for your elastic version.

as describe in the documentation you can use environment variable, you can try.
https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html

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