API monitoring works by periodically invoking the API from Talend Jobs and recording the response details. This article shows you one way of monitoring the API in a Microsoft Azure environment using a combination of Talend Jobs.
Sources for the project are attached in the Appendix section of this article.
Environment
This article uses the following in a Talend cloud environment:
Studio 7.3.1 downloaded from Talend Cloud portal
Talend in the cloud API Designer
Process flow
API Designer in Talend in the cloud
The first step in the process is to add a new endpoint, in this case, HTTP/health, to the API. The health check client periodically invokes the endpoint to check the health of the service instance.
API Services in Talend Studio
The next step adds a logic for the health endpoint in the API Services Job, along with the rest of the logic for the other endpoints. This Job gives the right message about API availability.
Creating an API Monitor Job
The API Monitor Job, creates a client that checks the health of the API instance. The Job reads input from a file, one record at a time, and iterates for all the APIs to be validated.
You can schedule the Job from Talend Management Console at regular intervals to collect the API details. Then push the details to the Azure log workspace and later pull them into the Azure Dashboards. The Job gets the following details:
API name
API status
API error message
Timestamp of when the API detail was collected
Creating the source file for the API Monitor Job
The input to the Job is a list of APIs endpoints with the API name.
Azure Dashboard
This Job pushes the data to an Azure log analytics workspace from where queries are written, and the API Monitor dashboards are displayed in Azure Dashboard.
Reviewing the individual queries and reports
Report—to know the overall API health stats
Query:
// to know the overall API health
talend_api_monitor_rek_CL
| project API_NAME_s, API_STATUS_s, API_RETURN_CODE_d,CURRENT_TIMESTAMP_s
| summarize count() by API_STATUS_s
| render piechart
Chart:
Report—to know the status report of the APIs in last 1 or 3 days
Query:
// to know the status of the API in last 1 day.
talend_api_monitor_rek_CL
| where TimeGenerated > ago (1d)
| project API_NAME_s, API_STATUS_s
| evaluate pivot(API_STATUS_s)
| render table
Chart:
Report—to know the error message for the unavailable API
Query:
//to know the error message for the unavailable API
talend_api_monitor_rek_CL
|where API_RETURN_CODE_d <> 200
|project API_NAME_s, ERROR_MSG_s,p= format_datetime(TimeGenerated,'MM-dd-yyyy')
|evaluate pivot(p)
|render table