Hi @loneWolf666,
One of our main Telegraf contributors took a look at your problem and came up with this solution. It will store each array as a string within a field. If you would rather each array item be its own field then you remove the starlark plugin.
Well if you just say data_format = "json"
without any other options you get (for the data in the thread linked above)
file,host=Hugin speed_0=0,odometer_2=9.5,points_2_y=-25.705089569091797,points_1_type=0,points_1_y=7.958527565002441,angle_1=0.09063859006636221,angle_2=0.35431448844127544,angle_5=0.35431448844127544,odometer_7=7.9,y=1111111.354243171,left_behind_at=1634607917.8445928,odometer_3=6.6000000000000005,odometer_4=9.9,odometer_5=10.100000000000001,points_2_type=16,odometer_1=9.1,distance=0,points_1_x=-26.048484802246094,speed_2=2,angle_6=-0.2609292744335221,angle_7=0.1785305561913333,odometer_6=9.5,speed_1=1,speed_3=4,angle_0=0.35431448844127544,angle_3=0.09063859006636221,angle_4=-0.08514534218357994,current_throttle=0,points_0_type=0,x=1111111.9858582001,odometer_0=9.9,gy=957004.5313795683,points_0_x=-27.771453857421875,points_0_y=7.960874557495117,points_2_x=14.540033340454102 1638445095000000000
as you can see it contains odometer_0
to odometer_7
. You can now use that metric in a starlark processor to concatenate those points to a string.
[[processors.starlark]]
source = '''
def apply(metric):
fields = ["angle", "odometer", "speed"]
for f in fields:
key_prefix = f+"_"
key_len = len(key_prefix)
keys = [x for x in metric.fields.keys() if x.startswith(key_prefix)]
keys = sorted(keys, key=lambda x: int(x[key_len:]))
values = [str(metric.fields.pop(k)) for k in keys]
new_value = "["+', '.join(values)+"]"
metric.fields[f] = new_value
return metric
'''
resulting in
file,host=Hugin points_0_y=7.960874557495117,points_0_x=-27.771453857421875,points_1_type=0,points_1_x=-26.048484802246094,points_2_type=16,points_2_y=-25.705089569091797,x=1111111.9858582001,distance=0,points_0_type=0,points_1_y=7.958527565002441,y=1111111.354243171,left_behind_at=1634607917.8445928,gy=957004.5313795683,points_2_x=14.540033340454102,current_throttle=0,angle="[0.35431448844127544, 0.09063859006636221, 0.35431448844127544, 0.09063859006636221, -0.08514534218357994, 0.35431448844127544, -0.2609292744335221, 0.1785305561913333]",odometer="[9.9, 9.1, 9.5, 6.6000000000000005, 9.9, 10.100000000000001, 9.5, 7.9]",speed="[0.0, 1.0, 2.0, 4.0]" 1638446377000000000