0

We are using Logstash to read new data from database and send it to Elasticsearch. We would like that this happens periodically, for example every minute. How can we start Logstash periodically? What is the best practice for doing this on Linux?

Uros
  • 2,099
  • 7
  • 23
  • 50
  • You can use Crontab – Raman Sailopal Jul 14 '17 at 11:19
  • You can use the `schedule` parameter of the `jdbc` input, see this answer: https://stackoverflow.com/questions/37613611/multiple-inputs-on-logstash-jdbc/37613839#37613839 – Val Jul 14 '17 at 11:28
  • @Val: If you post an answer I will accept it. Setting schedule => "*/1 * * * *" worked for me. – Uros Jul 14 '17 at 11:43
  • @jww: My question is about setting up Logstash and I can see many questions on that topic on StackOverflow (https://stackoverflow.com/questions/tagged/logstash). If you still think this is off-topic I will remove my question. – Uros Jul 14 '17 at 11:45

1 Answers1

6

You can use the schedule parameter of the jdbc input. In your case since you want to run this every minute, you'd use the following pattern */1 * * * *:

  jdbc {
    jdbc_driver_library => "/Users/logstash/mysql-connector-java-5.1.39-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name"
    jdbc_user => "root"
    jdbc_password => "password"
    schedule => "*/1 * * * *"              <--- schedule for running every minute
    statement => "select * from table1"
    type => "table1"
  }
Val
  • 207,596
  • 13
  • 358
  • 360