<%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. The mapping rule has to be available as a REST configuration file in JSON template (*.template) format according to the PRTG API definition for custom sensors.
The sensor can show the following:
- Values returned by a REST API in multiple channels
For details about the return value format, see section Custom Sensors.
REST Custom Sensor
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
Remarks
Limited to 50 Channels
PRTG does not officially support more than 50 channels per sensor. Depending on the data used with this sensor, you might exceed the maximum number of supported channels. In this case, PRTG tries to display all channels. Be aware, however, that you experience limited usability and performance.
Add Sensor
The Add Sensor dialog appears when you manually add a new sensor to a device. It only shows the setting fields that are required for creating the sensor. Therefore, you do not see all setting fields in this dialog. You can change (nearly) all settings in the sensor's Settings tab later.
The following settings in the Add Sensor dialog differ in comparison to the sensor's Settings tab.
|
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 is channelDiscovery. If you select this REST configuration, 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 available files in the \Custom Sensors\rest subfolder of the PRTG program directory on the probe system. To appear in this list, store the files as JSON template (*.template) in this subfolder.
Using custom scripts is not possible on hosted probes. To use custom REST configurations, add this sensor to a remote probe instead and save the file on the remote probe system.
To 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 details, see section Define Channels and Select Channel Values.
For detailed information on how to build custom sensors and for the expected return format, see section Custom Sensors.
Several REST configuration files are available by default. They are ready for use. You can also analyze them to see how to write your own REST configuration.
When using custom sensors on the cluster probe, copy your files to every cluster node.
|
Sensor Settings
Click the Settings tab of a sensor to change its settings.
Usually, a sensor connects to the IP Address or DNS Name of the parent device on which you created the sensor. See the device settings for details. For some sensors, you can explicitly define the monitoring target in the sensor settings. See below for details on available settings.
|
Sensor Name
|
Enter a meaningful name to identify the sensor. By default, PRTG shows this name in the device tree, as well as in alarms, logs, notifications, reports, maps, libraries, and tickets.
|
Parent Tags
|
Shows tags that this sensor inherits from its parent device, group, and probe. This setting is shown for your information only and cannot be changed here.
|
Tags
|
Enter one or more tags, separated by spaces or commas. You can use tags to group sensors and use tag–filtered views later on. Tags are not case sensitive. We recommend that you use the default value.
There are default tags that are automatically predefined in a sensor's settings when you add a sensor. See section Default Tags below.
You can add additional tags to the sensor if you like. Other tags are automatically inherited from objects further up in the device tree. These are visible above as Parent Tags.
It is not possible to enter tags with a leading plus (+) or minus (-) sign, nor tags with parentheses (()) or angle brackets (<>).
|
Priority
|
Select a priority for the sensor. This setting determines where the sensor is placed in sensor lists. A sensor with a top priority is at the top of a list. Choose from one star (low priority) to five stars (top priority).
|
Default Tags
restcustomsensor, restsensor
|
Timeout (Sec.)
|
Enter a timeout in seconds for the request. If the reply takes longer than this value, the sensor cancels the request and shows a corresponding error message. Enter an integer value. The maximum value is 900 seconds (15 minutes).
|
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.
If you use the POST method, use the content type, for example application/x-www-form-urlencoded, as HTTP header. In section HTTP Headers, select Use custom HTTP headers and enter the content type into the Custom HTTP Headers field.
|
Postdata
|
This field is only visible if you enable POST above. Enter the data part for the POST request here.
If you use the POST method, use the content type, for example application/x-www-form-urlencoded, as HTTP header. In section HTTP Headers, select Use custom HTTP headers and enter the content type into 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 field is only visible if your enable 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 simple username and password authentication.
- Basic authentication with Windows credentials from parent device: Use the Windows credentials from the parent device. For more information, see section Inheritance of Settings.
- Token: Use a JSON Web Token (JWT) or OAuth2 Bearer Token for authentication.
|
User
|
This field is only visible if you enable Basic authentication above. Enter a username for the REST API. Enter a string.
|
Password
|
This field is only visible if you enable Basic authentication above. Enter a password for the REST API. Enter a string.
|
Token
|
This field is only visible if you enable Token above. Enter a JWT or OAuth2 Bearer Token that is required by the REST API for authentication.
|
HTTP Headers
|
Define if you want to send custom HTTP headers to the target URL:
- Do not use custom HTTP headers
- Use custom HTTP headers
|
Custom HTTP Headers
|
This field is only visible if you select Use custom HTTP headers above. Enter a list of custom HTTP headers with their respective values that you want to transmit to the URL you defined above, each pair in one line. The syntax of a header-value pair is header1:value1.
If you enter more than one header-value pair, you must separate them with delimiters. The syntax is header1:value1|header2:value2|header3:value3
The sensor does not support the header field names user-agent, content-length, host.
Ensure that the HTTP header statement is valid. Otherwise, the sensor request cannot be successful.
If you selected the POST Request Method setting above, enter the content type, for example application/x-www-form-urlencoded, as custom HTTP header.
|
REST Query
|
This field shows 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&...]
The first part of the address is always inherited from the parent device's address. 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 would look like this:
/api/table.json?id=1&passhash=<passhash>&username=<username>&content=sensorxref&noraw=1&filter_basetype=probe&columns=totalsens=textraw
|
REST Configuration
|
Shows the REST configuration file that the sensor uses to map returned JSON or XML into sensor values. Once you have created the sensor, you cannot change this value. It is shown for reference purposes only. If you need to change this value, add the sensor anew.
|
|
Sensor Result
|
Define what PRTG does with the sensor results:
- Discard sensor result: Do not store the sensor result.
- Write sensor result to disk (file name: Result of Sensor [ID].txt): Store the last result received from the sensor to the \Logs\sensors subfolder of the PRTG data directory on the probe system (master node, if in a cluster). File names: Result of Sensor [ID].txt and Result of Sensor [ID].Data.txt. This is for debugging purposes. PRTG overwrites these files with each scanning interval.
This option is not available when the sensor runs on the hosted probe of a PRTG hosted by Paessler instance.
|
|
Primary Channel
|
Select a channel from the list to define it as the primary channel. In the device tree, the last value of the primary channel is always displayed below the sensor's name. The available options depend on what channels are available for this sensor.
You can set a different primary channel later by clicking the pin symbol of a channel on the sensor's Overview tab.
|
Graph Type
|
Define how different channels are shown for this sensor:
- 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.
This option cannot be used in combination with manual Vertical Axis Scaling (available in the channel settings).
|
Stack Unit
|
This field is only visible if you enable Stack channels on top of each other as Graph Type. Select a unit from the list. All channels with this unit are stacked 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 the following settings are inherited from objects that are higher in the hierarchy and should be changed there if necessary. Often, best practice is to change them centrally in the root group settings. For more information, see section Inheritance of Settings. To change a setting for this object only, disable inheritance by clicking the button next to inherit from under the corresponding setting name. You then see the options described below.
|
Click to interrupt the inheritance. See section Inheritance of Settings for more information.
|
The proxy settings determine how a sensor connects to a URL. You can enter data for an HTTP proxy server that sensors use when connecting via HTTP or HTTPS.
This setting only affects monitoring and it determines the behavior of HTTP sensors. To change proxy settings for the PRTG core server, see section System Administration—Core & Probes
The SSL Certificate sensor and the SSL Security Check sensor do not support HTTP proxies but you can configure connections via SOCKS proxies in the sensors' settings.
|
Name
|
Enter the IP address or Domain Name System (DNS) name of the proxy server. If you leave this field empty, no proxy is used.
|
Port
|
Enter the port number of the proxy. Often, port 8080 is used. Enter an integer value.
|
User
|
If the proxy requires authentication, enter the username for the proxy login.
Only basic authentication is available. Enter a string or leave the field empty.
|
Password
|
If the proxy requires authentication, enter the password for the proxy login.
Only basic authentication is available. Enter a string or leave the field empty.
|
|
Click to interrupt the inheritance. See section Inheritance of Settings for more information.
|
Scanning Interval
|
Select a scanning interval (seconds, minutes, or hours). The scanning interval determines the amount of time that the sensor waits between two scans. You can change the available intervals in the system administration on PRTG on premises installations.
|
If a Sensor Query Fails
|
Define the number of scanning intervals that the sensor has time to reach and check a device again in case a sensor query fails. Depending on the option that you select, the sensor can try to reach and check a device again several times before the sensor shows a Down status. This can avoid false alarms if the monitored device only has temporary issues. For previous scanning intervals with failed requests, the sensor shows a Warning status. Choose from:
- Set sensor to down immediately: Set the sensor to a Down status immediately after the first failed request.
- Set sensor to warning for 1 interval, then set to down (recommended): Set the sensor to a Warning status after the first failed request. If the following request also fails, the sensor shows an error.
- Set sensor to warning for 2 intervals, then set to down: Set the sensor to a Down status only after three consecutively failed requests.
- Set sensor to warning for 3 intervals, then set to down: Set the sensor to a Down status only after four consecutively failed requests.
- Set sensor to warning for 4 intervals, then set to down: Set the sensor to a Down status only after five consecutively failed requests.
- Set sensor to warning for 5 intervals, then set to down: Set the sensor to a Down status only after six consecutively failed requests.
Sensors that monitor via Windows Management Instrumentation (WMI) always wait at least one scanning interval before they show a Down status. It is not possible to immediately set a WMI sensor to a Down status, so the first option does not apply to these sensors. All other options can apply.
If you define error limits for a sensor's channels, the sensor immediately shows a Down status. No "wait" option applies.
If a channel uses lookup values, the sensor immediately shows a Down status. No "wait" options apply.
|
|
You cannot interrupt the inheritance for schedules, dependencies, and maintenance windows. The corresponding settings from the parent objects are always active. However, you can define additional settings here. They are active at the same time as the parent objects' settings.
|
Schedule
|
Select a schedule from the list. Schedules can be used to monitor for a certain time span (days or hours) every week.
You can create schedules, edit schedules, or pause monitoring for a specific time span. For more information, see section Account Settings—Schedules.
Schedules are generally inherited. New schedules are added to schedules that you already set up, so all schedules are active at the same time.
|
Maintenance Window
|
Specify if you want to set up a one-time maintenance window. During a maintenance window, the selected object and all child objects are not monitored. They are in a Paused status instead. Choose between:
- Not set (monitor continuously): No maintenance window is set and monitoring is always active.
- Set up a one-time maintenance window: Pause monitoring within a maintenance window. You can define a time span for a monitoring pause below and change it even for an active maintenance window.
To terminate an active maintenance window before the defined end date, change the time entry in Maintenance Ends to a date in the past.
|
Maintenance Begins
|
This field is only visible if you enable Set up a one-time maintenance window above. Use the date time picker to enter the start date and time of the maintenance window.
|
Maintenance Ends
|
This field is only visible if you enable Set up a one-time maintenance window above. Use the date time picker to enter the end date and time of the maintenance window.
|
Dependency Type
|
Define a dependency type. You can use dependencies to pause monitoring for an object depending on the status of a different object. You can choose from:
- Use parent: Use the dependency type of the parent object.
- Select a sensor: Use the dependency type of the parent object. Additionally, pause the current object if a specific sensor is in a Down status or in a Paused status caused by another dependency.
- Master sensor for parent: Make this sensor the master object for its parent device. The sensor influences the behavior of its parent device: If the sensor is in a Down status, the device is paused. For example, it is a good idea to make a Ping sensor the master object for its parent device to pause monitoring for all other sensors on the device in case the device cannot even be pinged. Additionally, the sensor is paused if the parent group is paused by another dependency.
To test your dependencies, select Simulate Error Status from the context menu of an object that other objects depend on. A few seconds later, all dependent objects are paused. You can check all dependencies under Devices | Dependencies in the main menu bar.
|
Dependency
|
This field is only visible if you enable Select a sensor above. Click the Search button and use the object selector to select a sensor on which the current object will depend.
|
Dependency Delay (Sec.)
|
This field is only visible if you enable Select a sensor above. Define a time span in seconds for dependency delay.
After the master sensor for this dependency comes back to an Up status, monitoring of the dependent objects is additionally delayed by the defined time span. This can prevent false alarms, for example, after a server restart, by giving systems more time for all services to start up. Enter an integer value.
This setting is not available if you set this sensor to Use parent or to be the Master sensor for parent. In this case, define delays in the parent device settings or in its parent group settings.
|
|
Click to interrupt the inheritance. See section Inheritance of Settings for more information.
|
User Group Access
|
Define the user groups that have access to the sensor. You see a table with user groups and group access rights. The table contains all user groups in your setup. For each user group, you can choose from the following group access rights:
- Inherited: Inherit the access rights settings of the parent object.
- No access: Users in this user group cannot see or edit the sensor. The sensor neither shows up in lists nor in the device tree.
- Read access: Users in this group can see the sensor and view its monitoring results. They cannot edit any settings.
- Write access: Users in this group can see the sensor, view its monitoring results, and edit its settings. They cannot edit its access rights settings.
- Full access: Users in this group can see the sensor, view its monitoring results, edit its settings, and edit its access rights settings.
For more details on access rights, see section Access Rights Management.
|
|
Click to interrupt the inheritance. See section Inheritance of Settings for more information.
|
Channel Unit Types
|
For each type of channel, define the unit in which data is displayed. If defined on probe, group, or device level, these settings can be inherited to all sensors underneath. You can set units for the following channel types (if available):
- Bandwidth
- Memory
- Disk
- File
- Custom
Custom channel types can be set on sensor level only.
|
Define Channels and Select Channel Values
In your REST configuration file, you have to 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.
Example
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:
/api/table.json?id=1&passhash=<passhash>&username=<username>&content=sensorxref&
noraw=1&filter_basetype=probe&columns=totalsens=textraw,upsens=textraw,
downsens=textraw,partialdownsens=textraw,warnsens=textraw,pausedsens=textraw,
unusualsens=textraw,undefinedsens=textraw,downacksens=textraw
This REST query returns some JSON, for example:
{
"prtg-version": "17.3.33.2517",
"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 a 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.
|
Several 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.
JSONPath
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.
The 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.
Example
To demonstrate the practical usage of JSONPath, we use this JSON example that a REST query might have returned as reference in this section.
{
"devices":[
{
"firmware":{
"id":"0.7",
"date":"2017-05-18T17:11:43.7049944Z",
"channel": "beta"
},
"networks": {
"a": {
"rx_bytes": 35985021,
"tx_bytes": 7229493,
"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
}
}
}
]
}
|
|
Root
|
The dollar sign ($) matches the root element of the JSON data.
|
Child
|
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.
Example
This expression matches 35985021 in the example above:
$.devices.0.networks.a.rx_bytes
You get the same result with this expression:
$["devices"][0]["networks"]["a"]["rx_bytes"]
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)"]
|
Wildcard
|
To match multiple values, you can use the asterisk symbol (*).
Example
This expression matches 35985021 and 40085321 in the example above:
$.devices[0].networks.*.rx_bytes
|
Recursive Descent
|
You can match all subitems of a node with two dots (..).
Example
This expression matches 7229493 and 55294975 and 7229472 in the example above:
$..tx_bytes
|
Union
|
You can match multiple children with [<key1>,<key2>,<...>].
Example
This expression matches 35985021 and 7229493 in the example above:
$.devices.0.networks.a["rx_bytes","tx_bytes"]
|
Slice
|
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.
Example
This expression matches 63685865 in the example above:
$.devices[-1:].networks.a.rx_bytes
|
Current
|
The @ symbol matches the current element.
Example
This expression matches 40.085321 and 55.294975 in the example above and can be used to receive a percentage value:
$.devices[1].networks.a.["rx_bytes","tx_bytes"](@/100000000*100)
|
Filter
|
You can filter matches with [?<expression>].
Example
This expression matches 35985021 in the example above because the first device is the only one with a beta channel:
$.devices[[email protected]=="beta"].networks.a.rx_bytes
|
Script
|
You can modify matches with (<expression>) and keys with [<expression>].
Example
This expression matches true and false in the example above because only the first device has a beta channel:
$.devices[*](@.firmware.channel=="beta")
|
Placeholder
|
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.
Example
This expression creates a JSON map from ids to the corresponding firmware channel and matches {"0.7":"beta"} in the example above:
{$.devices[#0].id:$.devices[*].channel}
This is an extension of the official JSONPath.
|
Constant
|
- Numeric constants as 64-bit floating point: 12345.678
- String constants with double quotes: "switch"
- Boolean constants: true and false
|
Operator
|
- Parentheses control the order of evaluation: (<expression>)
- Arrays with square 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 details, refer to the gval documentation.
The following operators and functions are available to calculate channel values.
|
|
Operator
|
Description
|
Operand Type
|
Output Type
|
Infix Modifiers
|
+
|
plus
|
number
|
number
|
-
|
minus
|
number
|
number
|
*
|
times
|
number
|
number
|
**
|
power of
|
number
|
number
|
%
|
modulo
|
number
|
number
|
/
|
divide
|
number
|
number
|
&
|
bitwise and
|
number
|
number
|
|
|
bitwise or
|
number
|
number
|
^
|
bitwise xor
|
number
|
number
|
<<
|
shift left
|
number
|
number
|
>>
|
shift right
|
number
|
number
|
Logical Infix Operators
|
>
|
greater than
|
number/string
|
bool
|
>=
|
equal or greater than
|
number/string
|
bool
|
<
|
less than
|
number/string
|
bool
|
<=
|
equal or less than
|
number/string
|
bool
|
==
|
equal
|
any
|
bool
|
!=
|
not equal
|
any
|
bool
|
=~
|
match regular expression
|
string
|
bool
|
!~
|
mismatch regular expression
|
string
|
bool
|
in
|
contains element
|
any, array
|
bool
|
&&
|
and
|
and
|
bool
|
||
|
or
|
or
|
bool
|
??
|
coalescence
|
any
|
any
|
Prefix Operators
|
-
|
negative
|
number
|
number
|
~
|
bitwise not
|
number
|
number
|
!
|
not
|
bool
|
bool
|
|
duration(start,end)
|
- Calculates the nanoseconds between start and end.
- Both parameters must be RFC3339 date time strings.
Example
duration($.devices[0].firmware.date, "017-05-18T17:11:43.7049944Z")
|
now()
|
- Returns the current date time in RFC3339.
Example
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.
Examples
number("10.5")
number("a", 16)
|
len(object/array/string)
|
- Returns the length of an array or string and counts the number of properties in a JSON object.
Example
len($..(number(@)))
This expression counts every number or string that can be converted into a number. It returns 13 in the example above.
|
sum(array-/object-of-numbers)
|
- Returns the sum of an array of numbers.
Example
sum([1,2,3])
This expression returns 6.
|
mean(array-/object-of-numbers)
|
- Returns the average value of an array of numbers.
Example
mean([1,2,3])
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.
Example
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.
Example
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.
Example
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": {
"result":[
{
"value": {
"Total bytes on device" + #0 + " in network " + #1: $.devices.*.networks[*](@.rx_bytes + @.tx_bytes)
},
"CustomUnit": "Bytes"
}
]
}
}
Every 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]
|
url
|
- Address of the REST API endpoint that returns JSON or XML
|
template
|
- Fully qualified path and file name of your REST configuration file used to map the JSON result to the sensor
|
passthrough
|
- No mapping, only returning the queried JSON or XML
- Useful to analyze XML that has been converted to JSON
|
channelDiscovery
|
- 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.
|
|
-authtoken <string>
|
- JWT or OAuth2 Bearer Token to send with the request in authorization header as Bearer
|
-authusername <string>
|
- Username for basic authentication
|
-authuserpwd <string>
|
- User password for basic authentication
|
-post <string>
|
- {1|0}
- Default: 0
- 0 results in a GET request.
- 1 results in a POST request.
|
-proxy <string>
|
|
-proxyusername <string>
|
- Proxy username with basic authentication
|
-proxyuserpwd <string>
|
- Proxy user password with basic authentication
|
-tlsignore <string>
|
- {1|0}
- Default: 0
- 1 accepts self-signed certificates on HTTPS connections
|
-customheaders <string>
|
|
-template
|
- Returns the discovered template if you use channelDiscovery.
|
-timeout <integer>
|
- Sensor timeout in seconds
- Default: 10
|
More
PRTG MANUAL
KNOWLEDGE BASE
Can I create a sensor to monitor the number of paused or unknown sensors?
MISCELLANEOUS
Paessler JSONPath
Paessler Gval
JSONPath Online Evaluator
Edit Channels
To change display settings, spike filtering, and limits, switch to the sensor's Overview tab and click the gear icon of a specific channel. For detailed information, see section Sensor Channel Settings.
Notification Triggers
Click the Notification Triggers tab to change notification triggers. For detailed information, see section Sensor Notification Triggers Settings.
Others
For more general information about settings, see section Object Settings.
Sensor Settings Overview
For information about sensor settings, see the following sections: