Logstash not working as a service

Hello,

I am new to ELK and am trying to set up monitoring on few of our application jobs using ELK stack. I could run the below query successfully and the data is reflecting on Kibana:

logstash -f /etc/logstash/conf.d/accessinfologs.conf

However when i try to set up logstash service, it fails with the below error:

Mar 14 11:38:55 vlcdbdd2 logstash[28237]: [2022-03-14T11:38:55,407][FATAL][logstash.runner ] An unexpected error occurred! {:error=>java.nio.file.AccessDeniedException: /usr/share/logstash/data/.lock, :backtrace=>["sun.nio.fs.UnixException.translateToIOException(sun/nio/fs/UnixException.java:90)", "sun.nio.fs.UnixException.rethrowAsIOException(sun/nio/fs/UnixException.java:111)", "sun.nio.fs.UnixException.rethrowAsIOException(sun/nio/fs/UnixException.java:116)", "sun.nio.fs.UnixFileSystemProvider.newFileChannel(sun/nio/fs/UnixFileSystemProvider.java:182)", "java.nio.channels.FileChannel.open(java/nio/channels/FileChannel.java:292)", "java.nio.channels.FileChannel.open(java/nio/channels/FileChannel.java:345)", "org.logstash.FileLockFactory.obtainLock(org/logstash/FileLockFactory.java:89)", "jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)", "jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorImpl.java:62)", "jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorImpl.java:43)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:566)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:471)", "org.jruby.javasupport.JavaMethod.invokeStaticDirect(org/jruby/javasupport/JavaMethod.java:373)", "RUBY.execute(/usr/share/logstash/logstash-core/lib/logstash/runner.rb:396)", "usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_1_dot_0_dot_1.lib.clamp.command.run(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:68)", "usr.share.logstash.logstash_minus_core.lib.logstash.runner.run(/usr/share/logstash/logstash-core/lib/logstash/runner.rb:282)", "usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.clamp_minus_1_dot_0_dot_1.lib.clamp.command.run(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:133)", "usr.share.logstash.lib.bootstrap.environment.(/usr/share/logstash/lib/bootstrap/environm
Mar 14 11:38:55 vlcdbdd2 logstash[28237]: ent.rb:93)", "java.lang.invoke.MethodHandle.invokeWithArguments(java/lang/invoke/MethodHandle.java:710)", "org.jruby.Ruby.runScript(org/jruby/Ruby.java:1205)", "org.jruby.Ruby.runNormally(org/jruby/Ruby.java:1128)", "org.jruby.Ruby.runNormally(org/jruby/Ruby.java:1146)", "org.jruby.Ruby.runFromMain(org/jruby/Ruby.java:958)", "org.logstash.Logstash.run(org/logstash/Logstash.java:163)", "org.logstash.Logstash.main(org/logstash/Logstash.java:73)"]}
Mar 14 11:38:55 vlcdbdd2 logstash[28237]: [2022-03-14T11:38:55,421][FATAL][org.logstash.Logstash ] Logstash stopped processing because of an error: (SystemExit) exit

Here is my logstash.yml file:

pipeline.batch.size: 125

  • pipeline.batch.delay: 5*
  • node.name: dlmlogstash*
    path.data: /var/lib/logstash
  • pipeline.id: main*
  • pipeline.workers: 2*
    path.config:/etc/logstash/conf.d/
    log.level: info
    path.logs: /var/log/logstash
    xpack.monitoring.enabled: true
    xpack.monitoring.Elasticsearch.username: elastic
    xpack.monitoring.Elasticsearch.password: passwd
    xpack.monitoring.Elasticsearch.hosts: ["http://10.177.36.103:9200"]

Could you please guide me to the right area I should focus on in order to set up logstash service.

Thanks and regards,
Ashiq Aboo Backer

logstash is trying to write to that file and is getting an exception. You need to check that the permissions allow the directory and file to be written to by whatever user logstash is running as.

Thank you so much! I think my chown skipped this hidden file. It works fine now! :slight_smile:

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