d.a.d.a
d.a.d.a

Reputation: 1406

Logstash not working when run as service

I am trying to run logstash on my Debian machine. The config file is simple for testing purposes:

input {  
    stdin {}
}

output 
{
    file {
        path => "/tmp/test_logstash"
    }
}

When I run the command sudo /etc/init.d/logstash start I get the output logstash started.

Now I type some sample input in my command line such as ls -lah, which should be written to /tmp/test_logstash as configured in the config file.

But the nothing is written and when I ask about the status of logstash I get the output logstash is not running.

All log files in /var/log/logstash are empty files.

When I run /opt/logstash/bin/logstash -f /etc/logstash/conf.d everything works fine, but I need to run it as a service in the background.

I am new to using logstash and maybe it's something very easy to solve but I couldn't find any solution yet.

It would be great if someone has a solution for this.

EDIT: Background is that I want to install and start logstash in an ansible playbook /opt/logstash/bin/logstash -f /path/to/config the playbook hangs in there as it is waiting for the command to be finished (wich will not be the case, because you have to quit logstash with ctrl + d then). Maybe there is an easier solution for that.

EDIT 2: The owner of /opt/logstash directory is the user logstash with group logstash. The init.d startup script for logstash is simply:

#!/bin/bash
/opt/logstash/bin/logstash -f /etc/logstash/conf.d

Thanks in advance.

Upvotes: 3

Views: 9066

Answers (2)

森森森
森森森

Reputation: 1

cat /var/log/logstash/logstash-plain.log

In my case, I ran this:

chmod -R 777 /var/lib/logstash

Upvotes: 0

patrick
patrick

Reputation: 97

Just use this command:

/opt/logstash/bin/logstash -f /etc/logstash/conf.d &

This will start the process in background.

Upvotes: 1

Related Questions