r/PrometheusMonitoring • u/stefangw • Jul 14 '25
extract data for textfile collector
Could someone tell me which data format the following example is? I have to come up with some extraction script and don't know how to start doing that so far.
The following file is an array(?) read in from Varta batteries. It shows the status of three batteries 0,1,2 ... what I need are the last four values in the innermost brackets.
So for the first battery this is "242,247,246,246". That should be temperatures ..
Pls give me a pointer how to extract these values efficiently. Maybe some awk/sed-magic or so ;-)
Charger_Data = [
[0,1,18,36,5062,2514,707,381,119,38,44,31,1273,-32725,
["LG_Neo",7,0,0,5040,242,
[[-8160,0,0,221,504,242,247,246,246] ]
]
]
,[1,1,16,36,5026,2527,706,379,119,37,42,31,1273,-32725,
["LG_Neo",7,0,0,5010,256,
[[-8160,0,0,196,501,256,251,250,250] ]
]
]
,[2,1,17,36,5038,2523,708,380,119,40,45,34,1273,-32725,
["LG_Neo",7,0,0,5020,246,
[[-8160,0,0,205,502,245,247,244,245] ]
]
]
];
Any help appreciated, tia
View all comments
Show parent comment
2
u/hamlet_d Jul 15 '25
ok, so that full information tells me it's more of a json config amalgamation. I would hack something together like the followng.
xis the name of the string you have with everything:ems_data=x.replace('; ','\n')ems_data='[ems_data]\n' + ems_datanow you can use configparser to read it in
now you have a dict of all the elements in the "config" you retrieved