Logstash filter jdbc_streaming: how to get the target value

(Roland A. Schmidt) #1

I use jdbc_streaming filter to get data from an Oracle database
and have something like this:

filter {
jdbc_driver_library => "..."
jdbc_driver_class => "..."
jdbc_connection_string => "jdbc:oracle:thin:..."
jdbc_user => "xxx"
jdbc_password => "xxx"
parameters => { "sql_par" => "my_id"}
target => "sql_result"
statement => "select 1234 sql_val from dual where :sql_par > -1000"

I thought, the value 1234 could be directly assigned to an existing field of the event.
But I did not find the correct syntax yet.
Using existing numeric or string fields in the "target =>" option, I got conversion errors.
So I used a new field "sql_result" and can see in a json output:

"sql_result" => [
[0] {
"sql_val" => 1234.0

So it looks for me like an array with one object!?
In the kibana index pattern menu, I see a number field "sql_result.sql_val".
In the kibana discover menu, I see:
sql_result:{ "sql_val": 1234 } # a single object!?

What is the correct syntax for a ruby (with "event.set" and "event.get") or a mutate filter
(with "existing_field" => "%{[xxxx]]}" or similar) to catch the value 1234 from "sql_result".

Thanks in advance

Jdbc_streaming - get clean target content - not the field name as well
(Guy Boertje) #2

If I understand correctly, you want to extract the number into a field.

try a mutate update with {"[sql_result]" => "%{[sql_result][0][sql_val]}"}

(Roland A. Schmidt) #3

That is exactly, what I wished to have! Thanks very much!

(system) #4

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