Create a custom id from a a database columns

Hello everyone,

I'm new to logstash. Currently, I'm trying to create a custom document_id from the concatenation of two database columns.
My sql query inside the jdbc is as follows:
statement => "SELECT TOP 10 name, age, address FROM ECRITURE"

and my output is as follows:

output {
elasticsearch {
document_id => "%{name}%{address}"
}

But, instead of getting a custom id composed of the name and the address, I only get the string "%{name}%{address}".
Anyone has an idea to how to treat this problem? Thank you

What does the generated event look like? Does it have the fields you expect it to?

Thank you for your reply. yes it does It looks like this.

{
"@timestamp" => 2018-12-18T14:48:01.251Z,
"name" => "random_name",
"age" => 10,
"address" => "Paris",
"@version" => "1"
}

and I get the following document id : "%{name}%{adress}" instead of random_nameParis.

If I understand the problem correctly, I need to pass the values of the columns from the jdbc to the output. I thought that calling them with the "%{column_name}" is enough. But, it doesn't work.

Looks fine to me. Does it make any difference if you instead use document_id => "%{[name]}%{[address]}"?

I got the following id back "%{[name]}%{[address]}".
Logstash still treats it as a string

Which version of the stack are you using?

The latest version

Sorry, it is actually the 6.4.0

Problem Solved.
Just in case someone else have the same problem, you only need to add an alias to the columns of the sql statement and then use those aliases in the output like this "%{alias_name}%{alias_address}"

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