What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

API JSON

Votes:

0

Your Vote:

Up

Down

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

api json live-data

Created on Aug 11, 2018 8:26:48 PM by  Michaël De Coninck (0) 1

Last change on Aug 13, 2018 6:05:10 PM by  Stephan Linke [Paessler Support]



8 Replies

Votes:

0

Your Vote:

Up

Down

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

Created on Aug 14, 2018 6:12:09 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Aug 14, 2018 10:52:32 AM by  Michaël De Coninck (0) 1



Votes:

0

Your Vote:

Up

Down

You're welcome :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 14, 2018 11:16:40 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Aug 14, 2018 5:46:12 PM by  Michaël De Coninck (0) 1

Last change on Aug 15, 2018 8:05:56 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 15, 2018 8:06:54 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Aug 15, 2018 8:12:06 AM by  lordmilko (2,132) 2 1



Votes:

0

Your Vote:

Up

Down

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

Created on Aug 15, 2018 8:40:32 AM by  Stephan Linke [Paessler Support]

Last change on Aug 15, 2018 8:40:42 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Aug 15, 2018 9:38:53 AM by  Michaël De Coninck (0) 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.