Hi!
I am working on a project that involves drawing a line in kibana using data from a csv file.
Csv file:
latitude,longitude
44.453538,26.086064
44.455499,26.086069
44.457815,26.086090
44.459435,26.086106
Config file:
filter {
csv {
separator => ","
skip_empty_rows => true
columns => [ "latitude","longitude" ]
}
mutate {
convert => ["latitude", "float"]
convert => ["longitude", "float"]
remove_field => ["message", "@version", "path", "host"]
}
mutate {
add_field => {
"[link_line][type]" => "LineString"
}
}
ruby {
code => "event.set('[link_line][coordinates]', [event.get('%longitude').each, event.get('%latitude').each])"
}
}
I know that my ruby code is incorrect, but I don't know how to write it, I'm new to this. I want to put the data from csv in link_line and, in kibana, to visualize a line from the first point (44.453538,26.086064) to the second point (44.455499,26.086069), from the second point to the third point and so on.
code => "event.set('[link_line][coordinates]', [[ 26.086064, 44.453538], [ 26.086069, 44.455499], [ 26.086090, 44.457815], [ 26.086106, 44.459435]])
This works properly, but I would like to take the data from the csv file
Result in cmd:
{
"link_line" => {
"coordinates" => [
[0] [
[0] 26.086064,
[1] 44.453538
],
[1] [
[0] 26.086069,
[1] 44.455499
],
[2] [
[0] 26.08609,
[1] 44.457815
],
[3] [
[0] 26.086106,
[1] 44.459435
],
],
"type" => "LineString"
},
"longitude" => 26.086069,
"@timestamp" => 2021-03-11T15:07:02.815Z,
"link_point" => "44.455499,26.086069",
"latitude" => 44.455499
}
I hope I was quite explicit and someone can help me.
Thanks,
Vince