how to create nested object from select columns in logstash

113 Views Asked by At

I am doing a select * from xxx to a database, I would need to know how to take two or three fields from that select (field1, field2, field3) and create an array with these values. Any suggestion on how to do it?

input {
  jdbc {
        jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/ifxjdbc-4.50.3.jar"
        jdbc_driver_class => "com.informix.jdbc.IfxDriver"
        jdbc_connection_string => "jdbc:informix-sqli://xxxxxxxx"
        jdbc_user => "***"
        jdbc_password => "****"
        schedule => "* * * * *"
        statement => "SELECT * FROM informix.test WHERE id_nvd_com > :sql_last_value"
        use_column_value => true
        tracking_column => id_nvd_com
        last_run_metadata_path => "/var/log/logstash/value/test_last_value.yml"
        tags => "test"
  }
}
filter { 
       xxxxxxxx
}

output {
  # Para ELK
    elasticsearch {
            hosts => "localhost:9200"
            index => "index_001"
            document_type => "hca_001_lgs"
            document_id => "%{clave1}%{clave2}"
            #user => "user"
            #password => "pass"
            #upsert => ""
            #action => "%{accion}"
            #action => "delete"
            doc_as_upsert => true
            manage_template => false
    }

}

I could create it like this, but it doesn't generate it as nested

filter{
mutate { 
    rename => { 

        "[clave1_tmp]" => "[objectClaves][clave1]" 

        "[clave2_tmp]" => "[objectClaves][clave2]"   

    }
  }
}
0

There are 0 best solutions below