Hey, I have a query which works fine while using the JDBC steam "statement" but it does not seem to work while using JDBC static.
Here's my JDBC_Stream configuration:
filter {
jdbc_streaming {
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://<address>:<port>/<db>"
jdbc_user => "user"
jdbc_password => "password"
statement => "SELECT name FROM db_table WHERE inet_aton(?) between ip_from_int and ip_to_int limit 1"
use_prepared_statements => true
prepared_statement_name => "the_info"
prepared_statement_bind_values => ["[clientip]"]
target => "result"
add_field => { isp_name => "%{[result][0][name]}" }
remove_field => ["result"]
}
}
And here's my JDBC_Static configuration:
filter {
jdbc_static {
loaders => [
{
id => "my_table"
query => "select ip_from_int, ip_to_int, name from ip_ranges"
local_table => "my_table"
}
]
local_db_objects => [
{
name => "my_table"
columns => [
["ip_from_int", "INT(10)"],
["ip_to_int", "INT(10)"],
["name", "VARCHAR(255)"]
]
}
]
local_lookups => [
{
query => "SELECT name FROM db_table WHERE inet_aton(?) between ip_from_int and ip_to_int limit 1"
prepared_parameters => ["[clientip]"]
target => "result"
}
]
add_field => { result_name => "%{[result][0][name]}" }
remove_field => ["result"]
loader_schedule => "0 */2 * * *"
jdbc_user => "user"
jdbc_password => "password"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://<address>:<port>/<db>"
staging_directory => "/var/logstash/jdbc_static/import_data/"
}
}
I'd be glad if anyone could help!