Input file and input jdbc

Hi

I want to get the name of the csv file and then that value use it in a select of another input in database

input {
file {
path => "C:/Users/a/Downloads/bucket/*.csv"
start_position => "beginning"
sincedb_path => "NULL"
tags => ["load_file"]
}
jdbc {
driver_jar_path => "C:\logstash-7.14.0\postgresql-42.3.1.jar"
driver_class => "org.postgresql.Driver"
connection_string => "jdbc:postgresql://database"
username => "postgres"
password => "postgres"
statement => ["SELECT sff,cc FROM public.table WHERE id=namefile"]
tags => ["select_db"]
}

}

That will persist the in-memory sincedb to a file called NULL in the working directory of logstash. If you do not want the sincedb persisted across restarts then set it to "NUL".

When the inputs are configured there are no events, so the configuration of an input cannot use a sprintf reference to a field on an event. However, filter plugins can.

You may be able to do it using a jdbc_streaming filter. That always returns an array of hashes (each array entry a row, each set of columns a hash, even if it is only one column). You could then use a split filter to get one event per row.

1 Like

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