Monitoring Any REST API Source With CA UIM
CA UIM 9.0.2 brings in many new features, including the ability to monitor any technology, service, or device utilizing native REST APIs. In this article, we will show you how to easily utilize the new CA UIM RESTMon probe to monitor any REST API endpoint. We will be monitoring the weather in London (temperature, humidity, and pressure) by polling the API of openweathermap.org.
Before we begin, it is important to understand a handful of important concepts.
An API is an application programming interface, or a set of rules that allow programs to talk to each other. REST comes from “Representational State Transfer” and is basically data presented in a convenient format for a client. When you put these two concepts together you get a RESTful API, a type of API that has predefined ways to communicate with it (e.g. GET, PUT, POST). REST APIs are present in mobile apps, business processes, and social networks, among other things. They are becoming more popular than ever to be agile for organizations going through a digital transformation and to be compliant with new data protection regulations.
A UIM probe is a small piece of software from CA Unified Infrastructure Management that performs a dedicated task (e.g. gather data from an online resource, like the RESTmon probe). CA UIM has become even more powerful with the addition of REST API monitoring through the RESTMon probe. By using data collected from any online resource, we can use the RESTMon probe to produce relevant insights for businesses.
The 3-step process to enable a RESTMon is very simple: download the RESTMon schema template, customize it to your needs, and then upload it to start monitoring your API.
Step 1: Deploy the RESTMon probe to a UIM Robot and download the schema from the new UIM Operator Console.
Figure 1: UIM Operator Console Settings.
Figure 2: RESTMon schema template download.
Rename the downloaded file called “default_schema.json” to your name of choice. However, please make sure you keep the “_schema.json” appendix as it is the required filename format. For our example, we will call it “openapiweather_schema.json”.
Step 2: Configure the schema with your REST API details and data to monitor.
We will edit the following sections:
- Schema Name: Specify your new schema name. We will choose “openapiweather”.
- URLs: Specify the identifier and URL of the endpoint to poll. You can define multiple REST endpoints in this section. For this example we will use:
- id: “London” (This variable can be any unique id).
- URL: “/data/2.5/weather?q=london &appid=<mytoken>” (REST endpoint of the openapiweather; we have hard coded the API key required for the endpoint in this example, but multiple authentication options are available (e.g. urltoken, bearer, etc.).
- Definition: Authentication and connection details. We will not use any authentication for this exercise.
- auth: “none”
- name: “openapiweather” (Note this value must match the schema name).
- Metrics: Definition of the data to collect. We have defined 3 metrics: temperature, pressure and humidity. For each of them we have specified several fields.
- The fields in the “uim” section refer to the UIM QOS that will accommodate the monitored data.
- Value is used to specify the JPath/XPath used to parse the endpoint and extract our data.
- URL references the endpoint to poll.
See the example below for polling temperature:
Figure 3: Metric section.
As you see, we have used an arbitrary “qos_name”. However the fields “metric_type”, “qos_unit”, “qos_abbr” and “qos_desc” must match any of the values listed in the supported CI metric types file, available in the RESTMon settings page.
Figure 4: RESTMon guidelines with Supported Metric Types
In this example, our source is the host name of the remote API and our target will be the unique identifier we have used for our endpoint in the “URL” section (e.g. London).
Step 3: Upload the RESTMon schema.
Figure 5: Schema upload
Give it a name and proceed to validation:
Figure 6: Schema validation
If the schema is validated, you should see a message like this: “Successfully processed schema openapiweather_schema.json as openapiweather.”
Now we are ready to create a profile and start monitoring the REST API. Create the initial template configuration under USM in the Unified Management Portal:
Figure 7: Setup of the custom probe created
Select metrics to monitor:
Figure 8: Selection of metrics to monitor
After some time, the metrics will show up in USM under the source and target we specified in the RESTMon schema and in the Operator Console Dashboads.
Figure 9: Visualization of RESTMon metrics in USM
Figure 10: Operator Console OOTB Dashboard for Custom Probes created via RESTMon
You can also enrich the data you monitor by leveraging the calculated_methods. This feature enables you to process the monitored data before storing it (e.g. convert EUR to Dollar, or MB to GB). You need to define them in the “calculated_method” section of the schema and use them in the metric section as you can see below. In this line, we are applying the calculation “convertBytestoGB” to the read value.
- calculation: “$value $convertBytestoGB”
RESTMon provides a set of out-of-the-box schemas such as Elasticsearch, Dell EMC, and Paloalto Firewall that you can leverage and reuse as well. In addition, the RESTMon profile deployments can be streamlined by using the powerful Monitoring Configuration Service; the alarm definition workflow is fully centralized via Alarm Policies.
Additional information about how to configure RESTMon can be found in docops. To learn more about how RESTMon enriches the comprehensive integration of CA UIM with the entire infrastructure ecosystem, check out our CA AIOps platform.