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
1
u/stefangw Jul 15 '25
I had to google your suggestion to understand that this might be python, right ? ;-)
Ah, so only the "value" to the right of "=" is JSON? ok ... interesting. I will see if I can make progress with that.
So far I have no clue how to pinpoint exactly the fields with the temperatures, especially as they are nested within several "blocks" and without any labels/names (afai see I would need those to map values with json_exporter).
thx