简体   繁体   中英

Setting up Logstash as a service

I installed logstash with a tar.gz package. I want to run as a service so that logstash can run automatically when the system reboots.

Currently it works on manual command sudo /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/Logstash_Config_File_for_AB_Report.conf --pipeline.workers 1 --path.settings "/etc/logstash"

But I want the logs to automatically process on running the start logstash command. How should I set it up?

logstash: 7.6 os: Ubuntu OS

Instead of using rpm, we need a method that runs as a service in the current installation plan.

conf file

input {
        s3 {
                bucket => "${bucket_name}"
                access_key_id => "${aws_access}"
                secret_access_key => "${aws_secret}"
                sincedb_path => "/data/Logstash_sincedb/ac_report"
                prefix => "test/acreport/"
        }
}
output {
  elasticsearch {
      hosts => ["${hosts}"]
      index => "qc-report"
          user => "${es_user}"
          password => "${es_pwd}"

  }
}

tail - logstash-plain.log file:

[2022-07-26T11:21:42,695][INFO ][logstash.javapipeline    ][main] Pipeline Java execution initialization time {"seconds"=>2.43}
[2022-07-26T11:21:43,049][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2022-07-26T11:21:43,195][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2022-07-26T11:21:44,271][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2022-07-26T11:22:01,899][INFO ][logstash.inputs.jdbc     ][main][cca7fc3253063752c1c91463f52a5052acd1e03cc9101109d1a83581a400ffb0] (0.110499s)
Select * from [log].[vw_ErrorLog] where StartTime >= '1970-01-01T00:00:00.000'
[2022-07-26T11:22:17,322][WARN ][logstash.runner          ] SIGINT received. Shutting down.
[2022-07-26T11:22:17,460][WARN ][logstash.runner          ] SIGINT received. Shutting down.
[2022-07-26T11:22:17,613][FATAL][logstash.runner          ] SIGINT received. Terminating immediately..
[2022-07-26T11:22:17,965][ERROR][org.logstash.Logstash    ] org.jruby.exceptions.ThreadKill

The best way to do it is to make this into an init.d script. Here is an example of this for logstash

https://gemfury.com/vistahigherlearning/deb:logstash/-/content/etc/init.d/logstash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM