Guidelines on MuleSoft Logging, Alerting,Visualizer,Monitoring & API Analytics

Debojyoti Chakraborty
The Mule Blog
Published in
7 min readJun 7, 2020

--

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.
How to view the System & Application log ?
Click on the download button to save the logs in local drive.Sometimes support team refers it to troubleshoot thread dump related issue.
Audit Log helps to monitor & track the user related interactions in Anypoint platform

DataWeave log(String, T):T function writes the input values as system log in the Anypoint studio console. It helps with debugging DataWeave scripts.

DataWeave log function reference https://docs.mulesoft.com/mule-runtime/latest/dw-core-functions-log

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

Log levels order

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.

Runtime manager console
It is required to declare the category of MuleSoft logger component to control the log level from Anypoint runtime manager
Above image depicts how we can manage the log level from Anypoint runtime manager when the log category is declared as a part of MuleSoft logger component.

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.

Aforementioned Anypoint Connectors are available for use with the Log Points feature (Link : https://docs.mulesoft.com/monitoring/log-points)

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 :

Click on the “+” icon to create a new Alert
Select the alert condition & message body to send an email to intended recipients with the details about alert
Once the Alert condition satisfies, Anypoint platform sends an email to the user inbox

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 :

Troubleshooting section in Visualizer dashboard helps to find out the external API which is failing
Dashboard to find out the average memory utilization for an API in Visualizer

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 :

Inbound average response time
Outbound average response time Monitoring
Tabular format of outbound api response time
Infrastructure monitoring

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.

Functional Monitor to track the API health status
History page highlights the report of each execution in api monitoring & the statistics of it
Details option shows the status of execution, the actual response received from the api endpoint & the assertion result.

Analytics dashboard provides real time insight on how consumers are interacting with the APIs

API Analytics dashboard

--

--

Debojyoti Chakraborty
The Mule Blog

MuleSoft Certified | Java Certified | Marathon Runner | Loves Cooking | Avid reader | Quick Learner