New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

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

Free PRTG
Download >>

 

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

 

Top Tags


View all Tags


How can I export historic data from the PRTG API?

Votes:

0

Your Vote:

Up

Down

I would like to get historic data from the PRTG API. How do I do this and what kind of information can I get?

api historical-data prtg sensor

Created on Nov 20, 2017 9:57:44 AM by  Brandy Greger [Paessler Support]

Last change on May 22, 2019 10:22:43 AM by  Maike Behnsen [Paessler Support]



1 Reply

Accepted Answer

Votes:

0

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 19 or later

Getting Historic Sensor Data from the PRTG API

The PRTG API allows you to pull historic sensor data from the web interface in XML, CSV, or JSON format using the Historic Data tab. You can request the results of each single monitoring request (called raw data), or you can let PRTG calculate averages of the data (for example, hourly or daily averages).

The API documentation contains all the information that you need to build your queries. You can run API calls from a supported browser in URL format. The URL call must include the PRTG website name, for example:

https://<your-PRTG-server>/api/historicdata.xml....

Limitations

There are some limitations to prevent potential server overload when you query historic sensor data via the PRTG API:

  • Maximum 40 days of data for raw data requests.
  • Maximum 500 days of data per API request for averages. If you try using a larger time span than 500 days, PRTG will automatically reduce it to 365 days.
  • Maximum 5 API calls per minute.

API Calls for Historic Data

There are three API calls for historic data tables. The first URL will give you the data in XML format, the second URL will respond with CSV data, and the third URL will return JSON.

Note: You must supply the object ID of a sensor as well as a start date/time sdate and end date/time edate. If you use the JSON call, additionally provide the parameter usecaption=1 to get more information than just the raw data table.

XML Format /api/historicdata.xml?id=objectid&avg=0&sdate=2017-01-20-00-00-00&edate=2017-01-21-00-00-00

CSV Format /api/historicdata.csv?id=objectid&avg=0&sdate=2017-01-20-00-00-00&edate=2017-01-21-00-00-00

JSON Format /api/historicdata.json?id=objectid&avg=0&sdate=2017-01-20-00-00-00&edate=2017-01-21-00-00-00&usecaption=1

Example

You can use the following example call to query historic data for a Core Health sensor with ID #1002 in CSV format: /api/historicdata.csv?id=1002&avg=0&sdate=2017-10-20-00-00-00&edate=2017-11-20-00-00-00

The avg (average) is 0 so raw data is displayed. The sdate is October 20th, 2017 at 12 A.M. and the edate is November 20th, 2017 at 12 A.M. The result is a spreadsheet (CSV) file where each sensor channel is a column.

API Call for Historic Graphs

You can also use an API call to display your historic sensor data in a graph in PNG format:

/chart.png?id=objectid&avg=15&sdate=2017-01-20-00-00-00&edate=2017-01-21-00-00-00&width=850&height=270&graphstyling=baseFontSize='12'%20showLegend='1'&graphid=-1

Using the example from above, the graph will look like this:

Historic Data Graph
Click to enlarge.

Common Parameters for Historic Data API Calls

You can use the following parameters for the historic graphs and data tables:

ParameterDescriptionPossible Values
idID of the specific sensorinteger value
sdateStart of the time span (date and time)yyyy-mm-dd-hh-mm-ss
edateEnd of the time span (date and time)yyyy-mm-dd-hh-mm-ss
avgAverage interval in seconds; use 0 to download raw data (= results of all single monitoring requests)integer value
width/heightWidth and height of the graph in pixelsinteger value
graphstylingbaseFontSize='x' sets the size of the font, showLegend='x' enables (1) or disables (0) the graph legendbaseFontSize='x'%20showLegend='x'

Running Reports from the Web Interface

You can query historic sensor data directly within the PRTG web interface from the main menu under Sensors | View Historic Data or via the Historic Data tab on a sensor's detail page.

Historic Data Query Builder
Click to enlarge.

  1. Choose the sensor you want to create a report for using the object selector, for example the Core Health sensor.
  2. Enter the start/end date and time of the data you want to review or use the quick range options.
  3. Select an average interval. The No Interval (Display Raw Data) option displays raw data only.
  4. Select an output format for the report data, for example HTML web page. This is a good option to check results before exporting to another file format.
  5. Optionally include percentile calculations.
  6. Click the Start button to retrieve the historic data report.

The HTML web page will look like this Historic Data Report Example
Click to enlarge.

Historic Data Query Builder

The query builder tool allows you to experiment with API calls. The tool automatically builds and tests your desired queries. You can find the tool under Setup | PRTG API | Live Data, section PRTG HTTP API: XML Table Query Builder.

Detailed HTTP API Documentation

For information about the HTTP API, see PRTG Manual: HTTP API.

More

Created on Nov 20, 2017 10:27:44 AM by  Brandy Greger [Paessler Support]

Last change on Jul 30, 2019 5:29:01 AM by  Maike Behnsen [Paessler Support]



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.