<%NUMBERING1%>.<%NUMBERING2%>.<%NUMBERING3%> PRTG Manual: Live Graphs

You can use live sensor graphs from PRTG in other web pages using the PRTG API. PRTG renders graphs as .png or .svg files. You can include them in other web pages.

icon-i-round-redAuthentication with username and passhash (or username and password) must always be included in each PRTG API request. See section Authentication for more information.

icon-speechExamples

Live graph as a .png file:

/chart.png?type=graph&width=300&height=160&graphid=2&id=0

Live graph as an .svg file:

/chart.svg?type=graph&width=300&height=160&graphid=2&id=0

icon-i-roundTo switch between PNG and SVG images, just change the file extension of /chart to .png or .svg.

icon-i-round-redThe URL does not start with /api. When placing these URLs on web pages, keep in mind that the URLs contain the account username and password/passhash. This can imply security issues. We recommend that you set up a dedicated read-only user account in PRTG that is member of a dedicated user group, for example, that only has read rights for the root group and all underlying entries or, even better, only for the object IDs that are used for graph URLs.

Parameters for Live Graph URLs (chart.png or chart.svg)

Parameter

Description

type

Must be graph

graphid

Select time span of the graph:

  • 0=live
  • 1=last 48 hours
  • 2=30 days
  • 3=365 days

width

Width of the image in pixels

height

Height of the image in pixels

id

The object ID of the desired graph object. This is usually the ID of a sensor.

graphstyling

Allow control of some graph styles:

  • Display legend: graphstyling=showLegend%3D%271%27
  • Hide legend: graphstyling=showLegend%3D%270%27
  • Control font size: graphstyling=baseFontSize%3D%27XX%27 (XX is the font size)
  • Control legend and font size at the same time: graphstyling=showLegend%3D%271%27+baseFontSize%3D%275%27

bgcolor

Background color of the PNG image, for example, #fffff. This affects the area that surrounds the graph.

icon-i-round-redThe value must be URL encoded, for example, %23fffff.

plotcolor

Color of the graph's plot area, for example, #fffff. This affects the whole area within the graph box.

icon-i-round-redThe value must be URL encoded, for example, %23fffff.

plotcolor1

Alternating color of the graph's plot area, for example, #fffff. This affects the tiles within the graph box alternating with plotcolor2. The result is a striped graph box.

icon-i-round-redThe value must be URL encoded, for example, %23fffff.

icon-i-round-redThis parameter is overwritten when using the parameter plotcolor.

plotcolor2

Alternating color of the graph's plot area, for example, #fffff. This affects the tiles within the graph box alternating with plotcolor1. The result is a striped graph box.

icon-i-round-redThe value must be URL encoded, for example, %23fffff.

icon-i-round-redThis parameter is overwritten when using the parameter plotcolor.

gridcolor

Color of grid lines in the graph's plot area, for example, #fffff. This affects the horizontal and vertical lines within the graph box.

icon-i-round-redThe value must be URL encoded, for example, %23fffff.

hide

Do not show defined channels in the graph. Use the ID of a channel to hide it. For example, use hide=-4 to not show the downtime channel in the graph. To hide more than one channel, use commas to separate the IDs.

Retrieving Chart Legends (JSON)

You can show the legend of a sensor graph (channel IDs, colors, units, channel names) in the JavaScript Object Notation (JSON) format.

icon-speechExample

Chart legend in the JSON format:

/api/chartlegend.json?id=sensorid

More

Knowledge Base: How can I use the PRTG Application Programming Interface (API)?

Application Programming Interface (API) Definition—Topics

Keywords: