Label individual instances of logstash through cmdline params


(Biswajit86) #1

is there a way to label individual instances of logstash ? I run multiple logstash instances on a host and it works fine. But when I run topbeat on the host, it identifies that same proc.name for all the instances

if there was a way to label individual instances by passing in identifiers in command line params, I can atleast grok the instance name and aggregate metrics per each individual logstash instance


(Andrew Cholakian) #2

Currently no. I'd recommend opening an issue here https://github.com/elastic/logstash . It makes sense in light of our recent metrics work where we'll be adding a node name!


(Fabien Baligand) #3

You can maybe get what you need using environment filter plugin.
It allows you to set a field value from an environment variable :

environment {
add_metadata_from_env { "logstash_instance" ⇒ "LOGSTASH_INSTANCE_ENV_VAR_NAME" }
}


(Biswajit86) #4

Thats a good idea, but I don't think it is applicable for my query. I need the nodename in the command line params, not in the logstash collector.

If i add this line in the logstash collector, it will identify the instance where these logs were collected from topbeat, not the actual node-name for which the data is collected.

That is something I did not know about thought, than you nonetheless


(Biswajit86) #5

Created Issue #4604


(Fabien Baligand) #6

OK.
So if you clearly need a marker in logstash command line (I mean command line visible using "ps"), I invite you to set "LS_JAVA_OPTS" environment variable just before calling bin/logstash.

Example :
LS_JAVA_OPTS="-Dlogstash.instance=ls1"
bin/logstash

Using this tip, your final command line that is running logstash is :
java ... -Dlogstash.instance=ls1 ...

LS_JAVA_OPTS allow you to add params to real logstash start command line.
For information, the "-Dkey=value" syntax let you to set a java system property.


(Biswajit86) #7

This one looks more promising. let me try that.


(system) #8