Logstash starts only with sudo using sudo /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/postgresql.conf

with sudo , it works without any issue
sudo /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/postgresql.conf

but if i run
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/postgresql.conf
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.headius.backport9.modules.Modules (file:/usr/share/logstash/logstash-core/lib/jars/jruby-complete-9.2.9.0.jar) to method sun.nio.ch.NativeThread.signal(long)
WARNING: Please consider reporting this to the maintainers of com.headius.backport9.modules.Modules
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
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
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[FATAL] 2020-05-11 12:15:54.819 [main] runner - An unexpected error occurred! {:error=>#<ArgumentError: Path "/usr/share/logstash/data" must be a writable directory. It is not writable.>, :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/settings.rb:489:in validate'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:271:in validate_value'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:182:in block in validate_all'", "org/jruby/RubyHash.java:1428:in each'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:181:in validate_all'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:284:in execute'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in run'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:242:in run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in run'", "/usr/share/logstash/lib/bootstrap/environment.rb:73:in '"]}
[ERROR] 2020-05-11 12:15:54.827 [main] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

user running logstash needs write access to the specified path. that’s why it only works with sudo

Thanks ptamba, I fixed this problem
But i still have onother issue

in /etc/logstash/logstash.yml
path.config: /etc/logstash/conf.d/*

when i run the cmd
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d
==>it works perfectly

but when i try to restart the logstash service
he didn't run My config files.

I find the problem,
Error: unable to load postgresql-42.2.12.jar from :jdbc_driver_library, file not readable (please check user and group permissions for the path)
Exception: LogStash::PluginLoadingError
Stack: /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.1/lib/logstash/plugin_mixins/jdbc/jdbc.rb:172:in block in load_driver_jars' org/jruby/RubyArray.java:1814:in each'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.1/lib/logstash/plugin_mixins/jdbc/jdbc.rb:167:in load_driver_jars' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.1/lib/logstash/plugin_mixins/jdbc/jdbc.rb:148:in load_driver'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.1/lib/logstash/inputs/jdbc.rb:273:in run' /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:328:in inputworker'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:320:in `block in start_input'

solution:

jdbc_driver_library => "/../../postgresql-42.2.12.jar"

Moving the pg jar from jdbc_driver_library to /usr/share/logstash/logstash-core/lib/jars simply puts the jar in the classpath so it's already available, and clearing out the jdbc_driver_library property stops logstash from calling these changed methods.

and remove from the file.conf
jdbc_driver_library => ""

it works perfectly

tail -f /var/log/logstash/logstash-plain.log

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