Specify logstash configuration on command line with docker Specify logstash configuration on command line with docker docker docker

Specify logstash configuration on command line with docker


Looking into the startup scripts inside the logstash docker image, one can find the following function in the logstash-core/lib/logstash/runner.rb file:

# where can I find the logstash.yml file?# 1. look for a "--path.settings path"# 2. look for a "--path.settings=path"# 3. check if the LS_SETTINGS_DIR environment variable is set# 4. return nil if not founddef fetch_settings_path(cli_args)  if i=cli_args.find_index("--path.settings")    cli_args[i+1]  elsif settings_arg = cli_args.find {|v| v.match(/--path.settings=/) }    match = settings_arg.match(/--path.settings=(.*)/)    match[1]  elsif ENV['LS_SETTINGS_DIR']    ENV['LS_SETTINGS_DIR']  else    nil  endend

So the solution seems to either pass --path.settings= (=-syntax with empty value) or set the LS_SETTINGs_DIR variable to a falsy value. And indeed:

$ docker run --rm -it docker.elastic.co/logstash/logstash-oss:6.0.0 \  --path.settings= -e 'input { stdin { } } output { stdout { } }'The stdin plugin is now waiting for input:


As Knittl stated --path.settings is consulted for logstash settings which are in a logstash.yml file that looks something like this (taken from the docker.elastic.co/logstash/logstash:6.1.2 image:

http.host: "0.0.0.0"path.config: /usr/share/logstash/pipelinexpack.monitoring.elasticsearch.url: http://elasticsearch:9200xpack.monitoring.elasticsearch.username: logstash_systemxpack.monitoring.elasticsearch.password: changeme

The problem is the path.config points to a directory containing only the default logstash.conf.

The solution with no side effects is:

$ docker run --rm -it docker.elastic.co/logstash/logstash-oss:6.0.0 \ --path.config="" -e 'input { stdin { } } output { stdout { } }'

This way the other settings in logstash.yml will persist.