JDBC does not create .logstash_jdbc_last_run

Everything worked OK, until I made some change I guess.
I tried everything - different computer, different conf, redownloading the logstash and the plugin. It just won't create the file. I tried specifying another path but it outputs an error of premission denied.
Running on windows 7 machine.
my conf:

input {
jdbc {
jdbc_driver_library => "ojdbc7.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "************"
jdbc_user => "**"
jdbc_password => "
"
#schedule => "
* * * *"
statement => "SELECT * FROM BUG WHERE to_date(bg_vts, 'YYYY-MM-DD HH24:MI:SS') > :sql_last_start"
}
}
filter {
date {
match => ["bg_vts", "YYYY-MM-dd HH:mm:ss"]
}
#if %{DATE} in [bg_closing_date]
ruby {
code => "event['duration'] = (event['bg_closing_date'] - event['bg_detection_date'])"
}
}
output {
elasticsearch {
hosts => "127.0.0.1:9201"
index => "logstash-oracle"
# document_id => "%{bg_bug_id}"
# action => update
}
stdout{}
}

The solution is here:

adding this code to inputs/jdbc.rb below the "stop" method:

def close
puts "closing"

update state file for next run

if @record_last_run
File.write(@last_run_metadata_path, YAML.dump(@sql_last_start))
end

close_jdbc_connection
end

1 Like