Guidelines on MuleSoft Logging, Alerting,Visualizer,Monitoring & API Analytics
Logging plays an inseparable parts in software engineering & it guides system administrator, support engineers & developers to troubleshoot an issue as quickly as possible.
Find out the different types of logs in Anypoint platform below:
- System Log: It is specific to MuleSoft runtime & “log4j.xml” configuration file is not accessible to an user.System logs contains log messages about the MuleSoft runtime life cycle (startup and shutdown) & status messages about MuleSoft application.
- Application Log: It is specific to MuleSoft application & “log4j.xml” configuration file is packaged inside MuleSoft application. It contains all log messages generated inside the Mule application, including System.out messages. We can configure custom log file appender to send application log data outside of cloudhub to external log file appender like splunk.
- Audit Log: It logs user interactions within Anypoint Platform, including logins, business groups creation, and environments creation.Only the organization owner can access all the audit logs data. It is useful to detect the access violations.
DataWeave log(String, T):T
function writes the input values as system log in the Anypoint studio console. It helps with debugging DataWeave scripts.
Log levels monitors the logging in Anypoint platform. An inadequate logging level will lead either to missing significant messages or to flood the logs with a lot of less important records.
Find out the different log levels & the guidelines for its usage :
- DEBUG level logs messages which could be useful in debugging an issue
- INFO level is designated for information related messages which tracks the progress of the mule flow
- WARN level is best suited for temporary problems or unexpected behavior
- ERROR level should contain technical issues that need to be resolved for proper functioning of the application
Log level order/priority : DEBUG < INFO < WARN < ERROR
Note: By default mule runtime shows INFO log level, so it ignores DEBUG or TRACE log level messages & logging is done asynchronously in cloudhub console. Synchronous logging happens for audit trail or for ERROR/CRITICAL messages.
We can change the log level from runtime manager console. First we need to click on setting & then we need to select “logging” tab.Once we are at “logging” tab, we can change the log level against the package name.
Note:
(1)To enable verbose log for database, we need set the log level as to DEBUG for the following package : “org.mule.extension.db”
(2)Likewise for http, we need to set the log level to DEBUG for the following package : “org.mule.service.http.impl.service.HttpMessageLogger”
(3)Likewise for salesforce, we need to set the log level to DEBUG for the following package : “org.mule.modules.salesforce”
(4)Likewise for anypoint mq, we need to consider the the following packages “com.mulesoft.extension.mq” & “com.mulesoft.mq”
(5)Likewise for FTP we need to consider following package “org.mule.extension.ftp” & for SFTP, we need to consider following package “org.mule.extension.sftp”
We can find more fine grained package names from the package explorer in Anypoint studio.
Best practices for application logging is (1) to capture contextual , relevant & meaningful information which doesn’t add any overhead (2) to provide log category in logging component because it will classify the log message & helps to determine whether to log the category/package in production or not (3) to use json logger to standardize the logging format in json structure.It comes with a lot of advantages.Find the details in the following reference :
Message logging policy in API Manager enables to log custom messages between policies & flow.This policy is capable of logging messages like incoming request payload, outgoing response payload, request attributes, response attributes etc. It is listed under “Troubleshooting” category & minimum mule runtime version required is 4.1.1.
Log point (also known as codeless logging) features in Anypoint platform allows to generate logs for apps and APIs in real-time and without writing any code [Titanium subscription & Manage setting permission in runtime manager is required to use log points]. It monitors & logs API request attributes such as path,host, method, request body etc. It also logs API response attributes such as status code,connection,response body etc.
Alerts in Anypoint platform enables an administrator to set up a platform event that sends an email notification when a resource exceeds a certain threshold such as (1) CPU usage (2) memory usage (3) event traffic, or to track specific events like (1) secure data gateway disconnected (2) worker not responding (3) deployment success (4) deployment failure (5) server deleted (6) server disconnected etc.
Find the steps for creating alerts :
Visualizer provides a real-time view of application network to (1)quickly identify issues (2) automatically map deployment dependencies (3) ensure whether best architectural patterns have been followed or not.It helps in impact analysis to pinpoint the areas causing an issue.
“User can segment the Visualizer by average response time,errors or throughput”
Find out various visualizer dashboard below :
Monitoring empowers the operation teams with real time API metrics to diagnose & prescribe solutions against any anomaly.
Find some of the useful out of the box monitoring dashboard below :
Functional monitoring spontaneously test the health status of APIs in a predefined interval and helps an user to take a guard against the event failures.It takes advantage of BAT (Blackbox Automated Testing) CLI (Command Line Interface) internally to schedule,run & monitor API testing.
Analytics dashboard provides real time insight on how consumers are interacting with the APIs