How to use NetCrunch data parsers with REST sensor

See how easy it is to use REST sensor in NetCrunch to get any data, and process it with parsers for counters and statuses. It can be added to any view as a widget for live visibility.

The easiest and basic scenario of using REST sensor in NetCrunch is to get data from any publicly accessible API. This article will present you how to measure temperature in your city by using OpenWeatherMap.org. The free plan is more than enough for use in NetCrunch since it limits its use to no more than 60 requests per minute. (NetCrunch usually performs one request per 5 minutes)

Access the Data

The first step is to create an account in OpenWeatherMap.org - it's mandatory to receive an API key used in the REST sensor - to make requests.

  1. Visit https://openweathermap.org/appid#get to register an account and receive an API key.
  2. Wait for about 10 minutes for the API key to become active
  3. To make sure that your API key is active, you can use this link:

    https://api.openweathermap.org/data/2.5/weather?q=London&units=metric&APPID=**YourApiKey**
    

    (Be sure you use your API key).

  4. If you receive proper data (data that doesn't contain error like 401) you are ready to configure parser. Copy data to a temporary file - it will be used as 'test data' in the parser.

Add Parser

Adding parsers in NetCrunch is simple, for this particular example we won't be writing any code, JSONPath is enough to process weather counters.

  1. Click on Monitoring in the top menu and select Data Parsers
  2. Click on + Icon in the bottom left corner to add new parser - give it a name - it's recommended to use the name of an API that it processes, to make the selection in sensors easy.
  3. Switch type to JSONPath
  4. Put data you received from API (the one you copied to a temporary file) to Test Data

Configuring counters using JSONPath is simple, the dotted notation is enough for a simple response from API, please refer to this article in our documentation.

  1. Click onAdd counter path
  2. Select the name of the first counter that will be extracted from Test Data e.g. City/Temperature (Celcius) to indicate unit.
  3. Click on the second field to add JSONPath and type: $..temp
  4. Switch to Result to see if counter appeared there, you should see something like on the image below. parser
  5. Add additional Counter like humidity e.g City/Humidity (Percent) - $..humidity
  6. You can add more, like the speed of the wind, visibility, etc.

Add the Sensor

The last step is to add the REST sensor

  1. Add api.openweathermap.org to the Atlas, you can skip device type discovery, and set it to Other (You can add a nice icon, too!)
  2. Add monitoring sensor, type REST in the search box and select REST HTTP
  3. Add Page Id - something that can easily distinguish this sensor, for example,Krakow Weather
  4. URL Path can be what we've used for the first time - you can edit it to monitor your city: data/2.5/weather?q=&units=metric&APPID=

For more information on what type of data you can get from OpenWeatherMap, visit https://openweathermap.org/api

  1. Make sure that Method is set to GET
  2. Select HTTPS as the connection
  3. Data format should be set to your parser Rest Configuration

After completing sensor configuration, you can click on the test button located in the top right corner

The test should be successfully executed - HTTP Response should be OK, and you should see your counters.

sensor_test

Add Alerts

After a successful test result, the last thing is to add alerts or collectors to see data about the weather in the Node Status - which later can be used in widgets located on various views.

  1. Open the sensor config again if you closed it
  2. Click on Add Collector
  3. Select
  4. Add counter -> Performance object should point at the one that you added in the parser, e.g., City Adding Collector
  5. Click on Add and close the window
  6. Name your collector and save it, then save sensor.

The Result

After adding collectors - you can see your counters in the performance tab on openweathermap.org node. performance_counters

You can use these counters to create friendly and informative views!

view

apidata parsersexternalhumidityparsingrequestrestsensortemperature

NetCrunch Network Monitoring

Network Maps, Dashboards, and Alerts.
Monitor anything. Network, cloud, config.