What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

REST API v2 - Query Historical Data

Votes:

0

Hi, I am trying to figure out a way to get the following metrics out of PRTG and into our reporting system. For each Device we need the total downtime in a specified fixed period, we will be basing this off the ping sensor for the device. e.g. between 01/10/22-31/10/22 Device X was down for 3min 35 seconds.

I have tried to use the UI for reporting but to be honest, its not easily customisable at all considering from the templates we need about 2% of the actual data and we need in an external company wide reporting system not just PRTG itself.

What options are there to obtain this data in an automated way from PRTG? The REST API would be ideal as it will fit into our existing solutions seamlessly however I cant see any details in the swagger interface for historical data only point in time data.

api prtg reporting

Created on Nov 16, 2022 8:02:54 AM



3 Replies

Votes:

0

Hello Alex,

Thanks for contacting us.

My recommendation is to use the PRTG APIv2

https://www.paessler.com/support/prtg/api/v2/overview#toc_18

First you will need to connect to your server

url = 'http://127.0.0.1:8080/api/v2' $token = (Invoke-RestMethod -Method 'POST' -Body '{"username": "<Enter Username>", "password": "Enter Password"}' ($url + '/session')).token $headers = @{'Authorization' = 'Bearer ' + $token}

Invoke-RestMethod -Headers $headers -Uri ($url + '/sensors?filter=' + [System.Web.HttpUtility]::UrlEncode('downtimetotal > 0'))

Please keep in mind that you can update the query accordingly or as needed and based on your needs. This is just a base.

Hope this helps.

Regards,

Miguel Aikens

Created on Nov 17, 2022 3:40:11 PM by  Miguel Aikens [Paessler Technical Support]



Votes:

0

Thanks Miguel, I have managed to get that working, however I am having a hard time interpreting the results. This looks like its bringing back all sensor data as far back as data is kept (1 year). So when you look at downtime_total, its actually a much larger number than just what may have occurred in the past month.

Looking at the v2 documentation http://server/api/v2/overview I cannot figure out a way to use a filter to bring back data between a period (01/xx/2022) (endday/xx/2022), is there a way to do this? Can you confirm the downtime_total parameter is in seconds? If its in seconds one of our servers that had 0 known downtime in the past month is listed as being down for 4.5 hours which definitely doesn't add up at all. Can you give me a bit more insight as to what the data actually refers to?

Thanks, Alex

Created on Nov 22, 2022 3:26:19 AM



Votes:

0

Hi Alex,

Glad you were able to make the get it working.

I did try on my side and couldn't find a way to actually filter it based on certain period or dates unfortunately. Here's more information about what you can do with the APIv2. https://www.paessler.com/support/prtg/api/v2/oas#/Probes/GetProbeOverview

If you would like to provide feedback in regards to the new API you can go it as well in the link above.

Regards,

Miguel Aikens

Created on Nov 22, 2022 6:57:51 PM by  Miguel Aikens [Paessler Technical Support]




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.