This article applies to PRTG Network Monitor 17.3.33 or later
Monitoring Bitcoin Rates from CoinDesk Using the REST Custom Sensor
As long as whatever you want to monitor provides a JSON/XML-based REST API, this should be fairly easy.
The Rest Custom (BETA) sensor will work with most REST-based endpoints that provide XML or JSON output.
For example, we can poll bitcoin exchange rates from coindesk.com using their API (api.coindesk.com). To do so, we need to do the following:
1. Locate the correct endpoint/URL to find out how the data looks
With the correct URL/endpoint at hand, open the API URL in a browser to see how the data looks. Get familiar with the data as the next step will be to create a template. For this particular example, we will use this URL/endpoint:
The data provided by this particular endpoint looks like this:
{
"time": {
"updated": "Feb 13, 2018 13:37:00 UTC",
"updatedISO": "2018-02-13T13:37:00+00:00",
"updateduk": "Feb 13, 2018 at 13:37 GMT"
},
"disclaimer": "This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org",
"chartName": "Bitcoin",
"bpi": {
"USD": {
"code": "USD",
"symbol": "$",
"rate": "8,574.7475",
"description": "United States Dollar",
"rate_float": 8574.7475
},
"GBP": {
"code": "GBP",
"symbol": "£",
"rate": "6,170.3540",
"description": "British Pound Sterling",
"rate_float": 6170.354
},
"EUR": {
"code": "EUR",
"symbol": "€",
"rate": "6,948.0064",
"description": "Euro",
"rate_float": 6948.0064
}
}
}
2. Create a template for use with the sensor in PRTG
The template is used to tell PRTG what information to read/parse and display (since the endpoint may provide a very large number of metrics that we don't need). You need to create this template based on the sensor's documentation.
Examples are available in the PRTG program directory:
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\rest\ |
For this particular example, we've come up with the following template:
{
"prtg":{
"description":{
"device":"api.coindesk.com",
"query":"/v1/bpi/currentprice.json",
"comment":"Used for polling the bitcoin quote from coindesk.com for monitoring in PRTG"
},
"result":[
{
"channel":"USD",
"value":$.bpi.USD.rate_float,
"float":1,
"decimalmode":"Auto",
"unit":"custom",
"customunit":"U$",
},
{
"channel":"GBP",
"value":$.bpi.GBP.rate_float,
"float":1,
"decimalmode":"Auto",
"unit":"custom",
"customunit":"£"
},
{
"channel":"EUR",
"value":$.bpi.EUR.rate_float,
"float":1,
"decimalmode":"Auto",
"unit":"custom",
"customunit":"€"
}
],
"text":"Updated: " + $.time.updated
}
}
The description block is used to make it clear what this template was designed for. It should include the device and query to make it clear to anyone how to use this template, but the fields are completely optional.
The most important bit is the result section, which includes all the channels and properties/metrics. Nodes from the JSON document can be referenced using the following notation/syntax: $.bpi.USD.rate_float
In this particular template, there are three channels (USD, GBP, and EUR). The sensor's text message is the content of the updated node from the XML document. Because the API may have its own "update interval", having this information in the sensor's overview can be helpful.
The template should be stored under the following path on the probe where the sensor will be deployed:
C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\rest\ |
3. Put it all together
Now that we have both a template file (we'll name the file coindesk.bitcoin.priceindex.template) and an endpoint we can poll, it's time to put it all together:
- 3.1 Create a new device with the following address: api.coindesk.com
- 3.2 Deploy a new REST Custom sensor and configure the following:
Timeout | 10s |
Rest Query | /v1/bpi/currentprice.json |
Scanning Interval | 10 Minutes |
REST Configuration | coindesk.bitcoin.priceindex.template |
- 3.3 Click Continue to create the sensor.
You can now keep up with the bitcoin exchange rate directly from within PRTG. You can also create limits for alerting and have notifications if you want to be informed in case the value goes above or below a specific threshold.
Similar Topics
Here's another example using one of the standard templates and Weather Underground:
Best Regards,
Luciano Lingnau [Paessler Support]
Add comment