Hello all,
I am trying to extract the last 'actual' recorded value of a sensor channel since it went offline. The resulte of /api/table.json?content=channels&output=json&columns=name,lastvalue_&id=12345 return 'no data' but I would need to have the last one which has data.
Any idea how to modify the query above ?
Thanks Michaël
Article Comments
Dear Dariusz,
I have tried that as well but the historicdata alse returns empty values e.g. {datetime: "3/10/2018 10:03:22", RX SNR: "", RX Lock: "", TX State: "", Modem State: "",…} Is there a way to filter out the empty records ? and do something like teh SQL equivalent of SELECT top 1* FROM data WHERE not rx_snr = "" ... or even better an ODBC interface
Thanks Michaël
Oct, 2018 - Permalink
Hi there,
That is not possible I am afraid. But as it is JSON you could simply look for the latest row that holds a value under the "lastvalue" column. This would be possible via a loop that goes through the data.
Best regards.
Oct, 2018 - Permalink
Hi Dariusz,
That would be very inefficient as I don't know when the last actual data was recorded, hence I would have to possibly load a lot of raw data before hitting tru edata. There must be a more efficient way to do this. Any filters maybe ?
Best regards Michaël
Oct, 2018 - Permalink
Hi Michaël,
This is a rather simple API which does not offer any extended SQL Syntax, especially because PRTG saves its data not in a SQL Database. So I am afraid there is no real simple way to accomplish this, other than iterating through the historic data to find the last row which holds data.
What do you exactly want to achieve? Do you want to read this value to a different system?
Best regards.
Oct, 2018 - Permalink
Hi Dariusz,
I would need to retrieve the last known good value which corresponds to the last known location on a map. Without this the application doesn't make sense anymore.
Thanks Michaël
Oct, 2018 - Permalink
Hi Michaël,
We understand that, but there is no API-Call for that. The only mentioned way is to iterate through the historic data to find the row with data. :(
Best regards.
Oct, 2018 - Permalink
Hi there,
That would only be possible when you query the historicdata instead. These need to be filtered for actual values:
You can find more information about the above call under "Setup > PRTG API > Historic Data".
Best regards.
Oct, 2018 - Permalink