Automate setting node.name to be the same as host name


#1

Hello

Nodes' names out of the box are just some random values, like "8akjns787k". For humans it's easier if these names are the same as names of the hosts running ELK (say, "host-001-dev" or something like that). I'm wondering if there's a way to automate setting node name to be the same as host name. If there are only few nodes in the system, it's easy to simply change it in the config (/etc/elasticsearch/elasticsearch.yml - see below). However, when the whole ecosystem grows bigger, it would be better (and easier) to automate it.

In my case the ELK stack runs on Debian Jessie.

# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
#
node.name: host001

So is there any way to do so?

Many thanks in advance for your suggestions.


My question seems to be the same as Setting Node ID, but the OP did not get any replies, so I decided to create a new thread.


(Ed) #2

You can just set an enviroment varable like ES_NODE=1

and do something like node.name= ${HOSTNAME}-${ES_NODE}

https://www.elastic.co/guide/en/elasticsearch/reference/2.1/setup-configuration.html#node-name


#3

@eperry thanks for the info. I forgot to mention that I'm running ELK v5.0, but it works just fine anyway.

Just in case someone has a similar problem in the future, here's the config:

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# elasticsearch
node.name: ${HOSTNAME}
#elasticsearch

Didn't have to set any environment variables.
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/settings.html

Thanks once again!


(Michael Salmon) #4

The way that I solved it is to set the node name on the command line using a -D. I run multiple nodes per host and so I add a suffix to indicate the node within the host. I also force the ports so that node 0 has ports 9300/9200 etc. I would advise against using the hostname as the can be quite long if you are collecting stats, I use the last few digits once the names get long.


#5

Thanks for the info. I will certainly look into it, should the need arise :slight_smile:


(system) #6

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