I have some csv, and with ruby i convert it to array , like this:
11;22;33;44;55
66;77;88;99;100
ruby {
code => '
m = event.get("message").split(";")
m.each_index { |x| m[x] = m[x].to_f }
event.set("[messages]", m)
'
}
Output is:
"hits" : [
{
"_index" : "array_werte_v1",
"_type" : "_doc",
"_id" : "6pKOgngBVrDB9qxVPT4F",
"_score" : 1.0,
"_source" : {
"path" : "/home/ofitz-elk/bueltmann/stab001/array_werte.csv",
"column1" : "66;77;88;99;100",
"host" : "ofitz_elk-ingest-node_0321",
"@version" : "1",
"@timestamp" : "2021-03-30T09:54:22.590Z",
"message" : [
66.0,
77.0,
88.0,
99.0,
100.0
]
i need additional array wit the count values of the array message like new field "message_count":
"hits" : [
{
"_index" : "array_werte_v1",
"_type" : "_doc",
"_id" : "6pKOgngBVrDB9qxVPT4F",
"_score" : 1.0,
"_source" : {
"path" : array_werte.csv",
"column1" : "66;77;88;99;100",
"host" : "host_0321",
"@version" : "1",
"@timestamp" : "2021-03-30T09:54:22.590Z",
"message" : [ 66.0, 77.0, 88.0, 99.0, 100.0 ],
"message_count" : [ 1, 2, 3, 4, 5 ]
]