Logstash service multiple configs


(Matt) #1

Hi,

Just getting started with Logstash and am trying to get the service started using multiple config files on CentOS.

My logstash.service configuration is as follows:

[Unit]
Description=logstash

[Service]
Type=simple
User=logstash
Group=logstash

Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.

Prefixing the path with '-' makes it try to load, but if the file doesn't

exist, it continues onward.

EnvironmentFile=-/etc/default/logstash
EnvironmentFile=-/etc/sysconfig/logstash
ExecStart=/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384

My logstash user has permission to the /etc/logstash/conf.d directory. If I append the line:

ExecStart=/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/

with the name of a config the service starts with that config.

Is it possible to pass the directory name into the service config and have Logstash parse all the configs or does all configuration need to be in one config. I've not been able to get a clear answer on this Googling.

Thanks


(Paris Mermigkas) #2

You can pass a directory as a config path indeed. Logstash will concatenate and sort (inputs->filters->outputs) all files found inside.
This means though that only properly formatted config files have to be inside the directory, any other files will make Logstash throw an error.


(Matt) #3

Thanks but that doesn't fully answer my query. I believe I've configured the service correctly (i.e. the line "ExecStart=/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/" ) but it doesn't pick up the configs in the directory. If I pass the full path directing it to a config it works ok.

Any ideas what I'm doing wrong?


#4

What about: "ExecStart=/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/*.conf"


(Matt) #5

That's got it! Thank you.


(system) #6

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