I want to export the monitoring data of PRTG to a .csv or .xml file on a daily basis. This way, I can analyze the data in my own software or import it to Microsoft Excel, for example.
How can I export raw sensor data automatically from PRTG?
Votes:
0
Best Answer
Votes:
1
This article applies as of PRTG 22
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.
Notes:
- The authentication with user name and passhash (or user name and password) must always be included in each request by using the user name and passhash (or user name and password) parameters. You can find the passhash in the PRTG web interface:
- 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 edate is 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
Created on Apr 5, 2018 1:36:41 PM by
Brandy Greger [Paessler Support]
Last change on Jun 1, 2022 8:17:18 AM by
Brandy Greger [Paessler Support]
21 Replies
Votes:
1
This article applies to PRTG Network Monitor Version 12 or later, as well as to previous (deprecated) versions
HowTo: Automatically Exporting PRTG's Raw Monitoring Data Into Daily CSV or XML Files
With PRTG Network Monitor, you can analyze your sensor data in various ways. Exhaustive reports for your whole network can be generated as well as historic data reports for single sensors. Still, there are people who just need the data of a sensor in a convenient format to do their own statistics in external programs or to use Excel to do additional computations based on the monitoring data. That is why we have included a XML and CSV export function in PRTG.
This function of the web interface is handy to export data every few days. But if you need daily data for one or more sensors an automatic solution is more comfortable. With the CSVExport command line tool finally there is a way to export data of many PRTG sensors with one single line of script! You can use it as an on-demand tool or combine it with Windows task scheduler. Don't be confused by the name - CSVExport is capable of both XML and CSV data export!
Getting Started
To try it out, download CSVExport from PRTG Tools Family and unpack it.
To run the tool you must supply following command line parameters:
- PRTG username (option -pu).
- PRTG password (option -pp).
- The IP address or hostname of the PRTG web interface (option -ps).
- The sensor ID (or a list of IDs) of the sensor(s) you want to export the data for (option -s). You can look up a sensor's ID under its detail overview page from within the PRTG web interface. The ID is the number written in parentheses behind the sensor name. By the way, the ID is also part of the sensor's webpage URL.
For example, a simple call may look like this:
csvexport -pu=prtgadmin -pp=prtgadmin -ps=192.168.0.10 -s=1001
This command line writes yesterday's data of the sensor "Probe Health" (ID 1001) into a CSV file in the directory where CSVExport is started. If a file already exists, it is not overwritten, but a number is appended to the file name. If you run this command once every day using scheduled tasks you will get a daily CSV file for the sensor 1001.
A big advantage of this tool is that you can export the data of many sensors with one single call. To do so, you only have to look up the IDs and enter them - separated by commas - behind the "-s" parameter. In this case, you will get a separate file for each sensor.
Advanced Options
With optional parameters, you can define a start and end date of the data you want to export or enter a different target file location and credentials, if necessary. You can also change file format to XML and even combine the data of multiple sensors into one file. Please see the manual that comes with the tool's download for a good description of all advanced options.
Notes
This tool was written by PRTG Tools Family (which is not associated with Paessler). Thanks for sharing it with the community! All Google Code tools have not been created and published by Paessler AG, so we are not able to support them officially.
More
If you have trouble opening the CSV files in Excel, please see The Comma and Semicolon Issue in Excel Due to Regional Settings for Europe
Created on Feb 3, 2010 9:31:56 AM by
Daniel Zobel [Product Manager]
Last change on Mar 15, 2018 3:49:16 PM by
Arne Seifert [Paessler Support]
Votes:
0
Hi,
I keep getting this error when I run this tool against our PRTG instance:
C:\My Documents\Downloads\PTF.CSVExport>CSVExport.exe -pu=<hidden> -pp=<hidden> -ps=http :<ip address hidden>:8080 -s=4544 -f:C:\Tools
Processing sensor 4544 Getting data for sensor 4544 0:The remote server returned an error: (404) Not Found.
Press any key to continue
Can you please let me know how can I fix this problem? I am able to hit this server through browser without any problem.
Thanks, Amar
Created on Jul 9, 2010 11:04:22 PM
Last change on May 10, 2012 12:27:16 PM by
Manischa Mittal [Paessler Support]
Votes:
0
Yes, I do know is somewhat late for you, but it may help others.
I first tried CSVExport.exe -pu=prtgadmin -pp=prtgadmin -ps=xx.xx.xx.xx -s=1003 I got a 404 too
At Home / PRTG Status in System Settings, it stated: web server url: xx.xx.xx.xx web server IPs: xx.xx.xx.xx web server ports: 8081 I suppose that 8081 is because I have a WSUS (using port 80)
I then tried CSVExport.exe -pu=prtgadmin -pp=prtgadmin -ps=xx.xx.xx.xx:8081 -s=1003 I don't get a 404 but a "Cannot connect with remote server". And just the same with -ps= xx.xx.xx.xx:8081
At last, I repeated the address wich appears when I click "PRTG Network Monitor" (web GUI) CSVExport.exe -pu=prtgadmin -pp=prtgadmin -ps=xx.xx.xx.xx -s=1003 (with HTTPS) and _success_ ! :-)
HIH somebody
RØ
Created on Oct 26, 2010 5:41:18 PM
Last change on May 10, 2012 12:26:34 PM by
Manischa Mittal [Paessler Support]
Votes:
0
hi, i'm using CSVExport to export my data in csv. currently i'm using sensor method. my problem now is i unable to set the sensor to be executed at time that i already set. can any one help me on this.
Votes:
0
Can not get this program to work. Links in KB are dead.
Try this csvexport -pu=prtgadmin -pp=(hidden but confirmed) -ps=https://xx.xxx.xxx.xxx -s=2465 -to=60 -f=C:\Tools
Get the following: The remote server returned an error: (400) Bad Request.
Please help!!! Getting this working will be the deciding factor of it we renew or not.
Votes:
0
Please check the url that is used for the –ps= parameter. Make sure that you are using the correct protocol and port number. Typing this url in your web browser should present you with the PRTG login page.
Votes:
0
Dear Daniel Zobel, I downloaded CSVExport.exe from PRTG Tool Family, and it worked OK with 2-3 sensors. But, I had some problems:
1. I can't export CSV file with a Router (Probe) sensor (has IP and contains multi-sensors) , eg: ID=12772, the output has error. CSVExport.exe -pu=prtgadmin -pp=******** -ps=<my_server_IP_address>:8888 -s=12772 -av=300 ==> 13.4.1.13 Processing sensor 12772 Retrieving sensor historic data The remote server returned an error: (400) Bad Request. 2. When I used the optional parameter -fc ==> It was not ok. The Output command ok, but the .csv file was empty (but data's size >17KB) CSVExport.exe -pu=prtgadmin -pp=******** -ps=<my_server_IP_address>:8888 -s=13018 -fc=DateTime ==> 13.4.1.13 Processing sensor 13018 Retrieving sensor historic data Exporting to CSV 5526:Completed at 26-05-2014 17.36 ==> What's wrong here?
And, Can I get the file of PRTG Network Monitor to Display All sensor ID and the their Description? Thank you very much and have a nice day!
Created on May 27, 2014 7:58:51 AM
Last change on May 27, 2014 9:21:09 AM by
Torsten Lindner [Paessler Support]
Votes:
0
You can only access data on a per-sensor basis. It is not possible to "download" the historic data from a device and so all the child sensors. You need to do this one-by-one for each sensor.
To get a list of all sensors and their IDs you can use the API. Please see "Setup"->"PRTG API"->"Live Data" for the details.
Votes:
0
Dear Torsten Lindner, And what's about the parameter "-fc=..."? I want some fields: datetime, traffic total, traffic in, traffic out. How can I use it? Thank you for helping me.
Votes:
0
This is something you need to consult the provider of the tool directly about: http://www.prtgtoolsfamily.com
Created on May 27, 2014 11:15:55 AM by
Torsten Lindner [Paessler Support]
Last change on May 27, 2014 11:16:09 AM by
Torsten Lindner [Paessler Support]
Votes:
0
Where I can download CVSexport tool? Pages http://www.prtgtoolsfamily.com not working now!
Votes:
0
Since January 2015 there is a new tool called PRTG Data Extractor BETA that allows you to export your PRTG monitoring data to a SQL Server for further reporting/analysis.
Head to this article for details.
Feedback on the tool is welcome.
Update: Please be aware that we won't be continuing/supporting the PRTG Data Extractor any longer.
Created on Jun 1, 2015 1:31:31 PM by
Luciano Lingnau [Paessler]
Last change on Mar 14, 2018 1:50:33 PM by
Gerald Schoch [Paessler Support]
Votes:
0
What about PDF export? Is it possible? Is it going to be possible in future versions?
Votes:
0
Hello Aineias Matis,
The reports feature within PRTG is able to generate PDF reports for any sensor type with 1 minute interval readings. Please visit the manual page for more details:
Best Regards,
Votes:
0
I have downloaded the software, but where to use it? Where do you enter these commands?
Votes:
0
Hello Peter,
thank you for contacting us.
Please review this. You need to download csvexport first, then you'll be able to run the application passing the appropriate parameters.
Best Regards,
Votes:
0
Can CSVExport automatically export PRTG's Raw Monitoring Data Into minutely CSV or XML Files (every Minute)? what about shorter time? for example each 15 seconds.
Votes:
0
Hello Nastaran,
thank you for your post.
If you need to query "live" data from PRTG, please check PRTG's HTTP API. Please note that low scanning intervals (smaller than 30 seconds) may have adverse performance implications on large setups, we recommend using scanning intervals above 30 seconds, and using such interval you should also only query the API every 30 seconds.
Please note that there are two distinct queries which can be used, one for the "current" value and one for historic data, you could for instance always query all values for the last 5 minutes every 5 minutes or so.
Best Regards,
Votes:
1
This article applies as of PRTG 22
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.
Notes:
- The authentication with user name and passhash (or user name and password) must always be included in each request by using the user name and passhash (or user name and password) parameters. You can find the passhash in the PRTG web interface:
- 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 edate is 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
Created on Apr 5, 2018 1:36:41 PM by
Brandy Greger [Paessler Support]
Last change on Jun 1, 2022 8:17:18 AM by
Brandy Greger [Paessler Support]
Votes:
0
Does this data extraction through API impact any performance of PRTG server when we extract the data?
Votes:
0
Hello,
indeed, extracting data puts quite a bit of load on the core server. I recommend to include a pause of a couple of seconds after each such API call in order to give the core server enough time to process the data query.
Add comment