Can CA APM monitor 4xx and 5xx class HTTP Status Codes in CA API Gateway (APIM)?

Document ID : KB000094185
Last Modified Date : 19/06/2018
Show Technical Document Details
This is a CA Application Performance Management (APM) - CA API Gateway (APIM) Integration through CA Precision API Monitoring.
We would like to monitor the 4xx and 5xx class HTTP status code in the CA API Gateways using CA APM, and receive alert notification about such error along with the details of the affected service. Can this be achieved?
CA Application Performance Management - CA API Gateway Integration using CA Precision API Monitoring
HTTP errors (for example the 4xx and 5xx class status code) are usually traced by ErrorDetector, which is a feature provided through the CA APM Java Agent.

In an APM-APIM integration, it only involves the EPAgent, which means, we cannot use the ErrorDetector to detect and report these HTTP errors in the gateways.

Having said that, if these HTTP errors are logged in a log, you can create a custom Log Reader plugin to read these error and send it to the EPAgent.

In CA APIM, the HTTP errors are usually logged into 2 places by default:

1. In the mysql DB into the audit tables
2. Into a text file called ssg log (default path: /opt/SecureSpan/Gateway/node/default/var/logs/ssg_0_0.log)

Attached is a custom LogReader plugin we've created to read from the ssg.log based on our internal test environment.
Below are the steps to implement this custom solution:

1. Copy & ssgLogReader.cfg to <EPAgent_Home>\epagent\epaplugins\apim
2. Copy the to <EPAgent_Home>\epagent\epaplugins\lib\perl\Wily

Note: This is a custom version of created by Haruhiko Davis.

3. In, create one Stateful Plugin for each ssg log you want to read from.

For example:

introscope.epagent.stateful.APIM1.command=perl /opt/apm105/epagent/epaplugins/apim/ -sleepTime 30 -logfileDir "/opt/SecureSpan/Gateway/node/default/var/logs/" -logfile "ssg_0_0.log" -configfile "ssgLogReader.cfg"

4. Using CA APIM Policy Manager, add an Audit Detail to log the errors in the exact format as shown below:

User-added image

Remember, the error message has to be in the exact format as follow:

Error: ${audit.details.lastFullText} happened on Gateway: ${ssgnode.hostname} for service: ${} [${service.resolutionUri}] and the full request URL is: ${httpRouting.url}

For example, the actual message in the log would look like this:

2018-06-19T12:39:42.675+1000 INFO    114082 com.l7tech.log.custom.serviceerror: -4: Error: Downstream service returned status (500). This is considered a failure case. happened on Gateway: for service: error1 [/error1] and the full request URL is: http://<ip_address>:8080/error1

5. A PerIntervalCounter metric will be created under the specific Gateway Service node in Introscope Workstation Investigator.

For example, this screen shot shows a metric for the count of HTTP 500 error per interval:

User-added image

6. You can then create an alert from this metric to receive notification accordingly.
File Attachments: