0

I have installed logstash-forwarder on a DigitalOcean Ubuntu droplet, along with my Rails app that I deploy with Capistrano. I know logstash-forwarder is installed because I can do sudo service logstash-forwarder restart.

I have configured logstash-forwarder to read from stdin with the following config:

{
  "network": {
    "servers": [ "<my logstash server>:5000" ],
    "timeout": 15,
    "ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt"
  },
  "files": [
    {
      "paths": [
        "/var/log/syslog",
        "/var/log/auth.log"
       ],
      "fields": { "type": "syslog" }
    }, {
      "paths": [ "-" ],
      "fields": { "type": "stdin" }
    }
   ]
}

…and I have configured Rails to send all logs to stdout instead of writing to disk. I’m not exactly sure where the logstash-forwarder binary lives, and I’ve tried telling Capistrano to run the following command:

RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.4 /usr/bin/env sudo /etc/init.d/unicorn_oddjob_production restart | /opt/logstash-forwarder/bin/logstash-forwarder

…But it fails with:

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@128.199.40.124: sudo exit status: 127
sudo stdout: Nothing written
sudo stderr: bash: /opt/logstash-forwarder/bin/logstash-forwarder: No such file or directory
…

I’m quite new to all this, so I’m not sure where I’m going wrong. So, how can I send unicorn’s stdout to logstash-forwarder’s stdin?

Jezen Thomas
  • 101
  • 2

1 Answers1

0

By the looks of it, logstash-forwarder is not where you expect in the remote machine. Please, see the error message:

sudo stderr: bash: /opt/logstash-forwarder/bin/logstash-forwarder: No such file or directory

Also, once this is addressed, I am not sure the fact of restarting the daemon using the restart option is going to do what you expect. The unicorn_oddjob_production process will die after stopping the current unicorn and spawning a new copy of it. Once this happens, the pipe will be closed and the logstash-forwarder will be shutdown.

Without being an expert on unicorn, I would try to setup its logging to a named pipe and have logstash-forwarder read from it. Please, see this example. It explains how to send the output to STDOUT. For a named pipe, it should be the same.

Hope this helps!

c-garcia
  • 166
  • 1
  • 6