This are the URLs given in the doc

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

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

Is there not a way, also, to use any time range like the one which are provided in the web pages, like 1 day, 7 days, today, yesterday, last week, last month, instead of having to calculate a start date from today's date before to configure the URL.

This could be very helpful for some cases. For example to configure a button with personnal html on a map just to have a look with 1 click on the graph of known periods or known cases without to go back to the PRTG session to do again all the choises.

If there are not such hidden functions, I think all the html and js file are already existing in PRTG to provide such a solution to non programmer customers.

This would lead to very simple API URLs:

/api/historicdata.csv?id=objectid&avg=0&daterange=yesterday

or

/chart.png?id=objectid&avg=15&daterange=lastweek&width=850&height=270&graphstyling=baseFontSize='12'%20showLegend='1'&graphid=-1


Article Comments

How about this as personal html, it dynamically produces the chart of sensor 2064 for the last three months

<html>

<head>
<script language="JavaScript">
function prtgdate(date)
  {
  //format date to yyyy-mm-dd-00-00-00
  var twoDigitMonth = date.getMonth()+1+"";
  if(twoDigitMonth.length==1) twoDigitMonth = "0" + twoDigitMonth;
  var twoDigitDay = date.getDate()+"";
  if(twoDigitDay.length==1) twoDigitDay = "0" + twoDigitDay;
  return date.getFullYear() + "-" + twoDigitMonth + "-"+ twoDigitDay + "-00-00-00"
  }
</script>
</head>

<body>

<script language="JavaScript">
var start = new Date();
// set startdate three months back
start.setMonth(start.getMonth() -3);
start = prtgdate(start);
// set enddate to today
end = prtgdate(new Date());
// request chart
window.open("https://example.com/chart.png?id=2064&avg=60&sdate="+start+"&edate="+end+"&login=demo&password=demodemo");
</script>

</body>
</html>

Dec, 2014 - Permalink

One note to the solution above, please consider using an average of at least 300 seconds (better 1 hour) as avg parameter in the call. A minute average in 3 months graph results on 129K values (meaning with 1 pixel per value the graph needs to be over 120000 pixel wide).


Dec, 2014 - Permalink

any answer for this?


Mar, 2021 - Permalink

any upadate on this issue?


Mar, 2021 - Permalink