Hello PRTG-Team,

I am trying to retrieve the last 20 values of a sensor in JSON. The problem I am facing is that the 'live data' request

/api/table.json?content=values&output=json&columns=datetime,value_&count=20&id=2168&noraw=1&usecaption=true returns

{"prtg-version":"18.3.42.1748","treesize":288,"values":[{"datetime":"10/08/2018 22:10:00 - 22:15:00","Ping Time":621.0000,"Minimum":615.8000,"Maximum":628.6000,"Packet Loss":0.0000,"Downtime":0.0000,"coverage":"100 %"},{"datetime":"10/08/2018 22:15:00 - 22:20:00","...

I would however need the actual 'live data' for each individual datapoint (ping in this case) and not the coverage values.

When I request the same from historicvalues I get each individual value but the problem is I don't know start and end date between last and last - 20 (or any other amount).

Is it normal that the 'live data' returns coverage between two points in time and not each individual value?

Thanks for sharing your wisdom Michaël


Article Comments

Well, that's what the historic data endpoint is for :) You can use PRTGapi and the following to retrieve the last 20 values: Get-Sensor -Id 2168| Get-SensorHistory -Count 20 The installation process is rather simply, disclosed here :)


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

Thank you Stephan, I must have missed the -Count parameter. Have a great day Michaël


Aug, 2018 - Permalink

You're welcome :)


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

Hi Stephan, I am afraid we're not there yet ... Is it possible to use the -count parameter in hystoric values when using the HTTP API I tried the following, but none seem to do what I need (in this case return the last 5 records)

/api/historicdata.json?id=2168&avg=0&sdate=2018-01-13-00-00-00&edate=2018-01-13-01-00-00&usecaption=1&count=5 Results in 5 records from start date (sdate) ... but we need the last 5 records

/api/historicdata.json?id=2168&avg=0&sdate=2018-01-13-00-00-00&edate=2018-01-13-01-00-00&usecaption=1&count=-5 Returns no data: {"prtg-version":"18.3.42.1748","treesize":0,"histdata":[]}

/api/historicdata.json?id=2168&avg=0&sdate=2018-01-13-00-00-00&edate=2018-01-13-01-00-00&usecaption=1&-count=5 Returns full hour (60 records) /api/historicdata.json?id=2168&avg=0&sdate=2018-01-13-01-00-00&usecaption=1&count=5 Return "Not enough monitoring data"

/api/historicdata.json?id=2168&avg=0&edate=2018-01-13-01-00-00&usecaption=1&count=5 Returns no data: {"prtg-version":"18.3.42.1748","treesize":0,"histdata":[]}

/api/historicdata.json?id=2168&avg=0&sdate=2018-01-13-00-00-00&edate=2018-01-13-00-00-00&usecaption=1&count=-5 Returns no data: {"prtg-version":"18.3.42.1748","treesize":0,"histdata":[]}

Are there any undocumented historicdata parameters ?

Thanks Michaël


Aug, 2018 - Permalink

Unfortunately not, you'll need to use PRTGapi explicitly for this; sorry if that was not clear :/


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

By default the historic data API orders from oldest to newest. To sort from newest to oldest, you need to specify sortby=-datetime

http://prtg.example.com/api/historicdata.json?id=2168&edate=2018-08-15-18-07-20&sdate=2018-08-15-17-07-20&avg=0&count=20&sortby=-datetime&username=prtgadmin&passhash=12345678

Note that in order to retrieve at least 20 records your start and end time must allow for that, based on your interval. If the average of this sensor is 60 seconds, a 1 hour period will ignore any count above 60 records. If your refresh interval is once a day, you'll want a start and end date of at least 20 days in order to get 20 records


Aug, 2018 - Permalink

My humble personage bows before your grandeur, oh mighty lordmilko - Thanks! :) On a serious note, I should've thought of that. Sorry @Michaël!


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

Humility and gratitude in the presence of Lordmilko ! @Stephan= Dungeons, no dragons


Aug, 2018 - Permalink