Hey there !
Im pulling data from a device via http-module (metricbeat).
Unfortunately the Data is put in mixed datatypes within one array (elasticsearch doesn't support these types of arrays)
First Example
{"_P_SUM3": [260.4908,"W"]}
Second Example
{ "_ULN": [[
224.2511,
225.7967,
226.3067],"V"]}
For the first example i was able to create a new field with the script processor.
{
"testpipeline" : {
"description" : "Data_Parsing",
"processors" : [
{
"script" : {
"lang" : "painless",
"source" : """
ctx.Psum = ctx.http.Janitza_Monti2._P_SUM3[0];
"""
},
"remove" : {
"field" : [
"http.Janitza_Monti2._P_SUM3",
]
}
}
]
}
}
My Question for Example 2 is how do i access these kinds of arrays in the script processor.
I tried using this term:
ctx.cosphi1 = ctx.http.Janitza_Monti2._COS_PHI[0][0];
But that doesn't work.
Second Question: Is it possible to create a field of objects with the script processor ? Like this structure ?
{
"new_field": {
"name": "my_name",
"value": "[value1, value2, value3]"
}
}