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

How to get sensor status historical data in json format?

Votes:

0

Hello, when I query sensor data via api it returns a lot of properties including "statustext" and "statusid". However historical data doesn't include status in it. How can I get historical status in json format?

I'm using this query to get historical data: /api/historicdata.json?id=2741&sdate=2017-05-23-00-00-00&edate=2017-05-23-24-00-00&username=[name]&passhash=[passhash]

Thanks!

api historic-data prtg

Created on May 25, 2017 12:56:28 PM



11 Replies

Votes:

0

Dear Zakhar

The historic data only contains numeric channel data. The sensor status value, or status text is not stored. Only the current status/text can be read, because the historic status or text is not recorded.

Created on May 25, 2017 2:48:16 PM by  Arne Seifert [Paessler Support]



Votes:

0

Thanks Arne,

How can I figure out if the sensor was Up or Down then? Historical data only returns "Value" and "Coverage", but neither of them seem to be making sense. What field can be used? And how to get those fields?

Created on May 25, 2017 4:58:03 PM



Votes:

0

Thanks Arne,

So what is the recommended way to find out whether ping sensor was up or down from the historical data?

Zakhar

Created on May 26, 2017 8:10:07 AM



Votes:

0

Dear Zakhar

Yes.

  • If the sensor scan fails, you get no data in the sense of empty output (except for coverage) If the sensor is down due to an error, this is the output (no values, but coverage.)
  • If there was not scan at all (for example because the sensor was paused, or PRTG was not running) no data is recorded. That means if you use raw data output without average, even those time stamps are missing. If you have averages instead, you get the output for the selected time span with the according coverage value for each average interval.
  • If the sensor was down due to a limit is something which is not checked when historic data is extracted.

Created on May 26, 2017 11:57:04 AM by  Arne Seifert [Paessler Support]



Votes:

0

Hi Arne,

So what exactly does value represent? I saw values equal 0%, 43%, 100% - What are those?

Can I assume if the coverage is 100% and value is 100% that means that the sensor was "Up" at the period of time, if the coverage is 100% and value is 0% the sensor was down, if both coverage and value is 0% then there is no data stored for the period?

I understand that I need to use avg parameter? I've noticed that it defaults to 5 minutes (300 seconds) is it right?

Created on May 26, 2017 2:05:47 PM



Votes:

0

Dear Zakhar

The default interval depends on the range. For example, if you query data for more than a months, you can only get hourly intervals as that is the minimum interval for that range.

Coverage means if the sensor itself was running at all and says nothing about up or down. Downtime is the coverage portion of downtime, meaning sensor error status.

If coverage is 100% and uptime is 100%, the sensor was up the whole time, that is correct. Your other two assumptions are correct as well.

Please clarify your first question (the one with the values.)

Created on May 29, 2017 11:22:31 AM by  Arne Seifert [Paessler Support]



Votes:

0

Hi Arne,

I asked what does the "Value" represent? You mentioned "Uptime" and "Downtime", but the historical api doesn't return neither of them, it returns "Value" and "Coverage". So what is the "Value"? Value of what?

This form doesn't let me attach images, bit I think I know what I mean.

Regards, Zakhar

Created on May 30, 2017 7:57:54 AM



Votes:

0

Ok, I see where the confusion is coming from, I use Postman app to test the api, and I just realised that I've been looking at "Prettified" response, where response objects look like this:

...
    {
      "datetime": "5/30/2017 12:00:00 AM - 12:05:00 AM",
      "datetime_raw": 42885.0034722222,
      "value": "0 %",
      "value_raw": 0,
      "coverage": "100 %",
      "coverage_raw": 10000
    },
...

In fact this is only part of the actual response object as the api returns invalid json with duplicated fields:

...
{
	"datetime": "5/30/2017 12:00:00 AM - 12:05:00 AM",
	"datetime_raw": 42885.0034722222,
	"value": "100 %",
	"value_raw": 100.0000,
	"value": "3 %",
	"value_raw": 3.0000,
	"value": "73 %",
	"value_raw": 73.0000,
	"value": "6,013 MByte",
	"value_raw": 6305165312.0000,
	"value": "0 %",
	"value_raw": 0.0000,
	"coverage": "100 %",
	"coverage_raw": 10000
}
...

If I request xml I get this which makes much more sense:

...
<item>
        <datetime>5/23/2017 12:00:57 AM</datetime>
        <datetime_raw>42878.0006680093</datetime_raw>
        <value channel="Health" channelid="0">100 %</value>
        <value_raw channel="Health" channelid="0">100.0000</value_raw>
        <value channel="System CPU Load" channelid="1">3 %</value>
        <value_raw channel="System CPU Load" channelid="1">3.0000</value_raw>
        <value channel="Available Memory Percent" channelid="2">66 %</value>
        <value_raw channel="Available Memory Percent" channelid="2">66.0000</value_raw>
        <value channel="Available Memory" channelid="3">5,369 MByte</value>
        <value_raw channel="Available Memory" channelid="3">5629648896.0000</value_raw>
        <coverage>100 %</coverage>
        <coverage_raw>0000010000</coverage_raw>
    </item>
...

I don't really need xml, is it possible to filter out the returned channel? I guess I only need "Health" channel really

Thanks!

Created on May 30, 2017 9:39:26 AM



Votes:

0

Dear Zakhar

The JSON output requires &usecaption=1 in the call to also output those properties. (JSON is often use internally and does not need those captions for the internal processing.)

Created on May 30, 2017 1:55:22 PM by  Arne Seifert [Paessler Support]



Votes:

0

Hi Arne, Ok, this is definitely helpful, are those parameters documented anywhere? I couldn't find any helpful historical data documentation.

Also, I'm having issues with the coverage, e.g. I'm requesting historical data for a short 30 minutes time interval, the api returns data that is outside of the interval, and has coverage "0 %" and empty channel values.

This is intermittent issue and I can't always reproduce it. Any thoughts on that?

Created on May 30, 2017 3:49:59 PM



Votes:

0

Dear Zakhar

Those parameters are not documented. The available historic data documentation is integrated in the web interface, via /api.htm?tabid=5 Only the most commonly used options are documented. We constantly develop the API further, internally used parameters can be changed or even deprecated in future versions. We rather document the part of the API which is considered stable.

If you get no data with an historic data API call, please check the sdate and edate, if you queried a time frame for which data exist.

Created on May 31, 2017 12:39:55 PM by  Arne Seifert [Paessler 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.