<%NUMBERING1%>.<%NUMBERING2%>.<%NUMBERING3%> PRTG Manual: REST Custom Sensor

The REST Custom sensor queries a Representational State Transfer (REST) application programming interface (API) endpoint and maps the JavaScript Object Notation (JSON) or Extensible Markup Language (XML) result to sensor values.

i_round_redThe mapping rule must be available as a REST configuration file in JSON template (*.template) format according to the PRTG API definition for custom sensors.

REST Custom Sensor

REST Custom Sensor

i_square_cyanFor a detailed list and descriptions of the channels that this sensor can show, see section Channel List.

Sensor in Other Languages

  • Dutch: REST Aangepast
  • French: REST personnalisé
  • German: REST (Benutzerdef.)
  • Japanese: REST カスタム
  • Portuguese: REST (customizado)
  • Russian: Специальные настройки REST
  • Simplified Chinese: REST 自定义
  • Spanish: REST (personalizado)


Consider the following remarks and requirements for this sensor:



File storage

  • The sensor requires that you store the REST configuration file that contains the mapping rules on the probe system. In a cluster, copy the file to every cluster node.


  • This sensor does not officially support more than 50 channels. If there are more than 50 channel mappings in the REST configuration file, the sensor shows an error.


  • This sensor supports IPv6.

Performance impact

  • This sensor has a medium performance impact.


  • In a cluster, status changes triggered by limits only work on the master node.

Hosted probe

i_podYou cannot add this sensor to the hosted probe of a PRTG Hosted Monitor instance. If you want to use this sensor, add it to a remote probe device.

Basic Sensor Settings

Basic Sensor Settings

Basic Sensor Settings

The sensor has the following default tags that are automatically predefined in the sensor's settings when you add the sensor:

  • restcustomsensor
  • restsensor

i_square_cyanFor more information about basic sensor settings, see section Sensor Settings.

REST Specific

REST Specific

REST Specific



Request Method

Select an HTTP request method to determine how the sensor requests the REST API:

  • GET (default): Use the GET method to request the REST API.
  • POST: Use the POST method to request the REST API.

i_round_blueIf you use the POST method, use the content type, for example application/x-www-form-urlencoded, as HTTP header. In section HTTP Headers, select Send custom HTTP headers and enter the content type in the Custom HTTP Headers field.


This setting is only visible if you select POST above.

Enter the data part for the POST request.

i_round_blueIf you use the POST method, use the content type, for example application/x-www-form-urlencoded, as HTTP header. In section HTTP Headers, select Send custom HTTP headers and enter the content type in the Custom HTTP Headers field.

Request Protocol

Define the security protocol of the HTTP request:

  • HTTP (default): Send the REST query via HTTP (not secure).
  • HTTPS: Send the REST query via secure HTTPS.

Certificate Acceptance

This setting is only visible if you select HTTPS above.

Select the kind of certificates that you want the sensor to accept for the connection:

  • Accept trusted certificates only (default): Accept only trusted certificates issued by a certificate authority (CA).
  • Accept all certificates: Accept all certificates, including self-signed certificates.

Authentication Method

Select the authentication method for access to the REST API:

  • No authentication (default): Do not use any authentication for the request.
  • Basic authentication: Use a user name and password for authentication.
  • Basic authentication with Windows credentials from parent device: Use the Windows credentials from the parent device.
    i_square_cyanFor more information, see section Inheritance of Settings.
  • Token: Use a JSON Web Token (JWT) or OAuth2 Bearer Token for authentication.

User Name

This setting is only visible if you select Basic authentication above.

Enter a user name for the REST API. Enter a string.


This setting is only visible if you select Basic authentication above.

Enter a password for the REST API. Enter a string.


This setting is only visible if you select Token above.

Enter a JWT or OAuth2 Bearer Token that the REST API requires for authentication.

HTTP Headers

Define if you want to send custom HTTP headers to the target URL:

  • Do not send custom HTTP headers
  • Send custom HTTP headers

Custom HTTP Headers

This setting is only visible if you select Send custom HTTP headers above.

Enter a list of custom HTTP headers with their respective values that you want to transmit to the target URL, each pair in one line. The syntax of a header-value pair is header1:value1.

i_round_redIf you enter more than one header-value pair, you must separate them with delimiters. The syntax is header1:value1|header2:value2|header3:value3

i_round_redThe sensor does not support the header field names user-agent, content-length, host.

i_round_redMake sure that the HTTP header statement is valid. Otherwise, the sensor request cannot be successful.

i_round_blueIf you select the POST as Request Method setting above, enter the content type, for example application/x-www-form-urlencoded, as the custom HTTP header.

Timeout (Sec.)

Enter a timeout in seconds for the request. Enter an integer. The maximum timeout value is 900 seconds (15 minutes).

i_round_blueIf the reply takes longer than this value, the sensor cancels the request and shows a corresponding error message.

REST Query

The REST query that this sensor executes. To change it, enter a valid query for the target REST API. The syntax is: [:port]/path[?var1=val1&...]

i_round_redThe sensor always inherits the first part of the address from the address of the parent device. Only enter the path to the REST endpoint of the parent device. You can override the port if necessary.

For example, if you add the sensor to a probe device, a query to the REST API of your PRTG installation that returns the number of sensors on the probe could look like this:


REST Configuration

Select a REST configuration file from the list. The sensor uses it to map the JSON or XML result from the REST query to sensor values.

The default REST configuration file is channelDiscovery. If you select this file, the sensor parses the returned JSON or XML and automatically creates channels based on available values: one channel for each number and boolean for strings if they are convertible into numbers.

This list shows all REST configuration files that are available in the \Custom Sensors\rest subfolder of the PRTG program directory on the probe system. For the files to appear in this list, store the files as JSON template (*.template) in this subfolder.

i_podTo use custom REST configurations in PRTG Hosted Monitor, contact the Paessler support team, or add this sensor to a remote probe instead and save the file on the remote probe system.

i_round_redTo show the expected values and sensor status, your files must return the expected JSON format. Channels, values, and messages must be embedded in valid JSON using JSONPath. For more information, see section Define Channels and Select Channel Values.

i_square_cyanFor more information on how to create custom sensors and for the return format, see section Custom Sensors.

i_round_redIf you use custom sensors on the cluster probe, copy your files to every cluster node.

Debug Options

Debug Options

Debug Options



Result Handling

Define what PRTG does with the sensor result:

  • Discard result (default): Do not store the sensor result.
  • Store result: Store the last sensor result in the \Logs\sensors subfolder of the PRTG data directory on the probe system. The file names are Result of Sensor [ID].txt and Result of Sensor [ID].Data.txt. This setting is for debugging purposes. PRTG overwrites these files with each scanning interval.

i_podThis option is not available when the sensor runs on the hosted probe of a PRTG Hosted Monitor instance.

i_round_blueIn a cluster, PRTG stores the result in the PRTG data directory of the master node.

Sensor Display

Sensor Display

Sensor Display



Primary Channel

Select a channel from the list to define it as the primary channel. In the device tree, PRTG displays the last value of the primary channel below the sensor's name. The available options depend on what channels are available for this sensor.

i_round_blueYou can set a different primary channel later by clicking b_channel_primary below a channel gauge on the sensor's Overview tab.

Graph Type

Define how this sensor shows different channels:

  • Show channels independently (default): Show a graph for each channel.
  • Stack channels on top of each other: Stack channels on top of each other to create a multi-channel graph. This generates a graph that visualizes the different components of your total traffic.
    i_round_redYou cannot use this option in combination with manual Vertical Axis Scaling (available in the channel settings).

Stack Unit

This setting is only visible if you select Stack channels on top of each other above.

Select a unit from the list. PRTG stacks all channels with this unit on top of each other. By default, you cannot exclude single channels from stacking if they use the selected unit. However, there is an advanced procedure to do so.

Inherited Settings

By default, all of these settings are inherited from objects that are higher in the hierarchy. We recommend that you change them centrally in the root group settings if necessary. To change a setting for this object only, click b_inherited_enabled under the corresponding setting name to disable the inheritance and to display its options.

i_square_cyanFor more information, see section Inheritance of Settings.

Define Channels and Select Channel Values

In your REST configuration file, you must define which values of the returned JSON or XML are mapped to which channels.

  • A channel is defined by the channel key in your REST configuration. See the JSON Return Format: Minimum Example in section Custom Sensors.
  • A channel value is defined by an expression that retrieves and processes the value from the JSON source. The expression can contain JSONPath, gval operators, and functions.


For this example, we take PRTG as REST endpoint and query the sensor status statistics for the local probe. The REST query that we enter in the sensor settings looks like this:



This REST query returns some JSON, for example:

   "prtg-version": "",
   "treesize": 1,
   "state": "ok",
   "sensorxref": [
       "totalsens": 28,
       "upsens": 18,
       "downsens": 0,
       "partialdownsens": 0,
       "warnsens": 0,
       "pausedsens": 9,
       "unusualsens": 1,
       "undefinedsens": 0,
       "downacksens": 0

Your REST configuration has to translate this JSON for the sensor. It has to be available as JSON template (*template) in the \Custom Sensors\rest subfolder of the PRTG program directory on the probe system. See section Custom Sensors for details about the JSON return format.

The following example returns two channels from the JSON resource that are added to the sensor in PRTG, Total (total sensor count) and Alarms (sensors in the Down status), each selected by their keys in the returned JSON.

   "prtg": {
     "result": [
         "channel": "Total" ,
         "value": $.sensorxref[0].totalsens
         "channel": "Alarms" ,
         "value": $.sensorxref[0].downsens

The channel values are the values of the corresponding properties of the REST result defined in JSONPath notation, $.sensorxref[0].totalsens (28) and $.sensorxref[0].downsens (0).

Each value's property (destination) and the text property is set to the appropriate transformation rules from source to destination. This is the JSON path of the source. The sensor replaces each path with the value from the source.

i_round_blueSeveral REST configuration files are available in the \Custom Sensors\rest subfolder by default. They are ready for use. You can also analyze them to see how to write your own REST configuration.


The REST Custom sensor uses JSONPath to assign values from the returned JSON to channels. With JSONPath, you provide the path to the value in the JSON source that you want to monitor in a channel.

i_round_blueThe JSONPath implementation that PRTG uses for the REST Custom sensor might differ from other JSONPath implementations. You can test and debug your definitions using the command line. To test simple JSONPath expressions and calculations, you can also use JSONPath Online Evaluator, for example. Note that this tool might not work properly with complex JSONPath expressions that PRTG supports.


To demonstrate the practical usage of JSONPath, we use this JSON example that a REST query might have returned as reference in this section.

     "channel": "beta"
   "networks": {
     "a": {
       "rx_bytes": 35985021,
       "rx_packets": 176791,
       "rx_errors": 0,
       "rx_dropped": 476,
       "tx_bytes": 7229493,
       "tx_packets": 35518,
       "tx_errors": 0,
       "tx_dropped": 1
     "b": {
       "rx_bytes": 40085321,
       "tx_bytes": 55294975
   "networks": {
     "a": {
       "rx_bytes": 63685865,
       "tx_bytes": 7229472

REST Custom Sensor: JSONPath


The dollar sign ($) matches the root element of the JSON data.


You can match a child with .<key> or [<key>].

  • .<key> must only contain letters, numbers, and underscore (_). Hyphens (-) are not supported.
  • [<key>] must only contain a number or a quoted string.


This expression matches 35985021 in the example above:


You get the same result with this expression:


If an element contains a hyphen (-), the .<key> notation does not work. Use the [<key>] notation in this case:

$["data"][0]["system-stats"]["temps"]["Board (CPU)"]


To match multiple values, you can use the asterisk symbol (*).

  • .*
  • [*]


This expression matches 35985021 and 40085321 in the example above:


Recursive Descent

You can match all subitems of a node with two dots (..).


This expression matches 7229493 and 55294975 and 7229472 in the example above:



You can match multiple children with [<key1>,<key2>,<...>].


This expression matches 35985021 and 7229493 in the example above:



You can match multiple children of an array with [<begin>:<end>] or [<begin>:<end>:<step>].

  • By default, begin, end, and step are either integers or empty.
  • The default approach is to go step by step from the first array element to the last element.
  • Step can also be a negative integer to go through the array in reversed order.


This expression matches 63685865 in the example above:



The @ symbol matches the current element.


This expression matches 40.085321 and 55.294975 in the example above and can be used to receive a percentage value:



You can filter matches with [?<expression>].


This expression matches 35985021 in the example above because the first device is the only one with a beta channel:



You can modify matches with (<expression>) and keys with [<expression>].


This expression matches true and false in the example above because only the first device has a beta channel:



Placeholders give access to values of wildcards in a match. A placeholder #n (where n is a natural number) represents the value of the nth wildcard. You can use this in the keys of JSON arrays.


This expression creates a JSON map from ids to the corresponding firmware channel and matches {"0.7":"beta"} in the example above:


i_round_blueThis is an extension of the official JSONPath.


  • Numeric constants as 64-bit floating point: 12345.678
  • String constants with double quotation marks ("): "switch"
  • Boolean constants: true and false


  • Parentheses control the order of evaluation: (<expression>)
  • Arrays with brackets: [<expression>, <expression>, ...]
  • Objects: {<expression>:<expression>, <expression>:<expression>, ...}
  • Conditionals: <condition> ? <expression> : <expression>

Calculating Channel Values and Functions

You can perform calculations with the values of the source JSON or XML. The sensor uses the Paessler gval package for the calculations. For more information, refer to the gval documentation.

The following operators and functions are available to calculate channel values.

REST Custom Sensor: Operators




Operand Type

Output Type

Infix Modifiers














power of












bitwise and




bitwise or




bitwise xor




shift left




shift right



Logical Infix Operators


greater than




equal or greater than




less than




equal or less than








not equal




match regular expression




mismatch regular expression




contains element

any, array














Prefix Operators






bitwise not







REST Custom Sensor: Functions


  • Calculates the nanoseconds between start and end.
  • Both parameters must be RFC3339 date time strings.


duration($.devices[0].firmware.date, "017-05-18T17:11:43.7049944Z")


  • Returns the current date time in RFC3339.


duration($.devices[0].firmware.date, now())

number(string, [base])

  • Converts a string to a floating point number.
  • If the base is not set, it is detected via the prefix of the string.
    • "0": base = 8
    • "0X": base = 16
    • otherwise: base = 10
    • Decimals are only supported at base 10.


number("a", 16)


  • Returns the length of an array or string and counts the number of properties in a JSON object.



This expression counts every number or string that can be converted into a number. It returns 13 in the example above.


  • Returns the sum of an array of numbers.



This expression returns 6.


  • Returns the average value of an array of numbers.



This expression returns 2.

lookup(string, string, string, ...)

  • Returns the index of the specified string in a string list, or -1 if the string is not found.


lookup($.device[0].firmware.channel, "stable", "beta", "alpha")

This expression returns 1 because $.device[0].firmware.channel resolves to beta.

implode(array-/object-of-string, string)

  • Returns the concatenation of each string in the array, separated by the specified string.


implode($..tx_bytes, ",")

This expression returns 7229493,7229472.

Generic Channels

You can create a template in your REST configuration that defines generic channels. Generic channels are created based on the data that the REST endpoint returns. When the returned value is an array or object, the sensor creates a channel for each element and concatenates the corresponding key to the channel name.


Imagine that you want to have a total byte channel for each network card that is defined in the JSON example above. You can do this by creating a dynamic channel like in the following example.

 "prtg": {
       "value": {
         "Total bytes on device" + #0 + " in network " + #1: $.devices.*.networks[*](@.rx_bytes + @.tx_bytes)
       "CustomUnit": "Bytes"

i_round_blueEvery channel must have a unique name. You cannot remove channels once they have been added and they keep their last received value. You can add new channels.

XML Sources

If the REST source returns XML instead of JSON, the sensor transforms the XML result to JSON before replacing the value paths with source values. Because of this, you do not know the structure of the source JSON to correctly provide the paths.

In this case, manually execute the sensor executable rest.exe from the \Sensor System subfolder of the PRTG program directory on the probe system. Execute rest.exe with the address of the XML endpoint and the parameter passthrough. The rest executable returns the converted XML to a JSON result that you can use to define the desired paths.

rest.exe <xml-endpoint-url> passthrough

Usage and Debugging

To create a suitable REST configuration for the sensor, you might want to check the returned JSON or XML and see what happens when your mapping rules apply.

The REST Custom sensor is an EXE sensor, so you can test and debug your configuration by executing rest.exe with several parameters. The rest.exe file is located in the \Sensor System subfolder of the PRTG program directory.

The command syntax is as follows:

rest.exe url template|passthrough|channelDiscovery [flags]

rest.exe: Parameters


  • Address of the REST API endpoint that returns JSON or XML


  • Fully qualified path and file name of your REST configuration file used to map the JSON result to the sensor


  • No mapping, only returning the queried JSON or XML
  • Useful to analyze XML that has been converted to JSON


  • Creates a channel for every number or boolean in the returned JSON or XML
  • If possible, it converts string values to number or boolean values.

rest.exe: Flags

-authtoken <string>

  • JWT or OAuth2 Bearer Token to send with the request in authorization header as Bearer

-authusername <string>

  • User name for basic authentication

-authuserpwd <string>

  • User password for basic authentication

-customheaders <string>

  • key1:val1|key2:val2|...


  • {1|0}
  • Default: 0
  • 0 results in a GET request.
  • 1 results in a POST request.


-customheaders 'Content-Type: application/x-www-form-urlencoded' -post=1 -requestbody 'myvar=value'

-proxy <string>

  • Proxy server connection

-proxyusername <string>

  • Proxy user name with basic authentication

-proxyuserpwd <string>

  • Proxy user password with basic authentication

-requestbody <string>

  • Body of the request

i_round_blueYou can only use this flag a POST request (-post=1).


-customheaders 'Content-Type: application/x-www-form-urlencoded' -post=1 -requestbody 'myvar=value'

-timeout <integer>

  • Sensor timeout in seconds
  • Default: 10


  • {1|0}
  • Default: 0
  • 1 accepts self-signed certificates on HTTPS connections


  • Returns the discovered template if you use channelDiscovery.

Channel List

i_round_blueWhich channels the sensor actually shows might depend on the target device, the available components, and the sensor setup.




In the channel table on the Overview tab, this channel never shows any values. PRTG uses this channel in graphs and reports to show the amount of time in which the sensor was in the Down status

Response Time

The response time

i_round_blueThis channel is the primary channel by default.


The values that a REST API returns in several channels

i_square_cyanFor more information about the return value format, see section Custom Sensors.


i_square_bluePRTG MANUAL


i_square_blueKNOWLEDGE BASE

What security features does PRTG include?

Can I create a sensor to monitor the number of paused or unknown sensors?



Paessler JSONPath

Paessler Gval

JSONPath Online Evaluator