How can I start logstash from a script

Background: I have logstash and elasticsearch running on a server. I have a rails application which uploads a CSV to the server and logstash then processes. It works if I manually execute the generated script. If I try to have rails do a system command, I get an error.

Manually call the script from server (WORKS)

logstash_folder/execute_random.sh

Rails app system command(ERROR)

logstash_folder/execute_random.sh

Error: WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults

execute_random.sh (script being called)

#!/bin/bash
sudo systemctl stop logstash
sleep 1
sudo /usr/share/logstash/bin/logstash -f logstash_folder/conf_folder/logstash.conf

Looking over this blog WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash - #15 by MrNerd

I change the script to include `--path.settings

sudo /usr/share/logstash/bin/logstash --path.settings /etc/logstash/ --path.data -f logstash_folder/#{self.logstash_index}/#{self.logstash_index}.conf"

& recieve this error

ERROR: Unknown command 'logstash_folder/conf_folder/logstash.conf

OR

    [INFO ][logstash.config.source.local.configpathloader] No config files found in 
    path {:path=>"/logstash_folder/conf_folder/logstash.conf"}
    [ERROR][logstash.config.sourceloader] 
    No configuration found in the configured sources.
```Preformatted text

Where is your config file located? The logstash process is looking for it in the folder /logstash_folder/conf_folder/logstash.conf, does this path exists?

How are you running your script manually, from which directory? And from which directory are you running your rails app?

Try to use the full path in your command, use -f /full/path/to/the/config/file.conf.

Thanks for the quick reply.
The config file does exist in that directory, it is executed when I run the shell script. I will try giving a full path...
2nd, as for manual ...inside the shell script mentioned "execute_random.sh" will execute logstash. so from my unbuntu server I would just run ./logstash_folder/execute_random.sh and it processes...

/home/
user/
dev/
lsa-demo/
logstash_folder/ **Generated scripts

EDIT### Changed .conf
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults

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