This article applies as of PRTG 22
I want to export the monitoring data of PRTG to a .csv or .xml file on a daily basis to analyze the data in my own software or import it to Microsoft Excel. How to achieve this?
Exporting historic sensor data into .csv or .xml files with the PRTG API
The PRTG API allows you to export historic sensor data into .csv or .xml files. This is useful if you need sensor data in a format that allows you to view your own statistics in external programs or for additional computations.
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 and credentials, for example:
https://<your-PRTG-server>/api/historicdata.xml?....&username=myuser&passhash=mypasshash
API calls for historic data in CSV or XML format
The following API calls give you historic data tables, either in CSV or XML format.
- Select Setup | Account Settings | My Account from the main menu bar.
- Click the Show passhash button.
You must supply the object ID of a sensor as well as a start date/time sdate and end date/time edate to get the raw data table. You can find the object ID on a sensor’s Overview tab or by hovering over the sensor in the device tree, for example.
CSV format
/api/historicdata.csv?id=objectid&avg=0&sdate=2018-01-20-00-00-00&edate=2018-01-21-00-00-00&username=myuser&passhash=mypasshash
XML format
/api/historicdata.xml?id=objectid&avg=0&sdate=2017-01-20-00-00-00&edate=2017-01-21-00-00-00&username=myuser&passhash=mypasshash
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=2018-02-01-00-00-00&edate=2018-02-15-00-00-00&username=myuser&passhash=mypasshash
The avg (average) is 0, so raw data is displayed. The sdate is February 1st, 2018 at 12 A.M and the edateis February 15th, 2018 at 12 A.M. The result is a spreadsheet (.csv) file where data of each channel is represented in an individual column.Common parameters for historic data API calls
You can use the following parameters for the historic graphs and data tables:
Parameter | Description | Possible values |
---|---|---|
id | ID of the specific sensor | integer value |
sdate | Start of the time span (date and time) | yyyy-mm-dd-hh-mm-ss |
edate | End of the time span (date and time) | yyyy-mm-dd-hh-mm-ss |
avg | Average interval in seconds; use 0 to download raw data (= results of all single monitoring requests) | integer value |
width/height | Width and height of the graph in pixels | integer value |
graphstyling | baseFontSize='x' sets the size of the font, showLegend='x' enables (1) or disables (0) the graph legend | baseFontSize='x'%20showLegend='x' |
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 in the PRTG web interface under Setup | PRTG API | Historic Data, section Historic Data Query Builder.
Detailed HTTP API documentation
You can find detailed documentation on all HTTP API functions in the PRTG Manual: Application Programming Interface (API) Definition.
Automatic export
If you want to automatically export historic data of several sensors at once, you can use the CSVExport command-line tool. It allows you to export data into both .csv and .xml files. See PRTG Tools Family for more information.
Limitations of the PRTG API for historic data
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 to use a larger time span than 500 days, PRTG will reduce it to 365 days automatically.
- Maximum 5 API calls per minute
More
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.