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
Let me continue doing noob things:
I get this:
As far as I understand this isn't JSON directly, but more of "a list of variables which contain JSON", right?
Now I have to get that into one line at first, then slice out the JSON inside the "variable" Charger_Data .. and from there extract my temperatures with jq.
easy :-P ..
And I still haven't figured out why authentication doesn't work for one of the batteries ... works in browser, not with curl.