linkedin

ELK Grafana Integration with Anypoint Studio Logs (Complete Walkthrough)

Introduction

In this blog, we explain how ELK Grafana Integration enables Anypoint Studio application logs to be centralized, analyzed, and visualized effectively. As a result, development teams gain better visibility into Mule application behavior during local development.

The ELK stack, provided by Elastic, consists of three open-source components: Elasticsearch, Logstash, and Kibana. Elasticsearch stores and indexes log data, while Logstash collects and processes incoming logs. Kibana then allows users to search, analyze, and visualize those logs through an interactive interface.

Meanwhile, Grafana is an open-source analytics and visualization platform designed to query, visualize, and monitor data from multiple sources. In simple terms, Grafana transforms raw log and metric data into meaningful dashboards and charts.

Although Kibana already provides visualization capabilities, Grafana becomes essential when monitoring metrics such as CPU usage, memory consumption, disk activity, and long-term trends. Therefore, Kibana primarily focuses on log analysis, whereas Grafana excels at metric-driven visualization.

Note that this walkthrough focuses on Anypoint Studio logs rather than CloudHub logs. However, approaches for externalizing CloudHub logs are discussed in the conclusion.

ELK Stack and Grafana Setup Prerequisites

Before starting, ensure the following components run locally:

  • ELK stack components: Elasticsearch, Logstash, and Kibana
  • Grafana
  • Anypoint Studio

Download the latest versions of the following tools from their official websites to access current features and improvements:

  • Elasticsearch
  • Logstash
  • Kibana
  • Grafana

Procedure Overview

This walkthrough uses Windows installations for all tools. However, the same configuration approach applies to macOS or Linux with minor command differences.

Setting Up Elasticsearch Locally

First, unzip the downloaded Elasticsearch package and navigate to the bin directory. Then, start Elasticsearch by running the elasticsearch.bat file.

Once Elasticsearch starts successfully, verify it by opening the following URL in a browser:

http://localhost:9200

At this point, a JSON response displaying node and version information confirms that Elasticsearch is running correctly.

Running Kibana for Log Analysis

Next, unzip the Kibana package and run kibana.bat from its bin directory.

After startup, confirm that Kibana is active by visiting:

http://localhost:5601

As a result, the Kibana web interface loads and becomes ready for log visualization.

Generating Logs from Anypoint Studio

Now, create a simple Mule application in Anypoint Studio to generate logs. This sample application logs a dummy payload to the console when accessed through port 8081.

After deploying the application, invoke the endpoint using Postman or another API client. At this stage, logs appear only in the Studio console.

The goal of ELK Grafana Integration is to forward these Studio logs to the ELK stack and visualize them using Kibana and Grafana.

Configuring log4j2 for Log Forwarding

To externalize logs from Anypoint Studio, update the log4j2.xml file of the Mule application.

Configure a socket appender that sends logs to a local TCP port, such as port 4560. Consequently, Logstash listens on this port to receive application logs.

After updating the log4j2 configuration, the Anypoint Studio setup for log forwarding is complete.

Logstash Pipeline Configuration

Next, extract the Logstash package and navigate to the config directory. Create a custom Logstash configuration file with a .config extension.

At a high level, a Logstash configuration includes three sections:

  • Input, which listens for incoming logs
  • Filter, which parses and structures log data
  • Output, which forwards logs to Elasticsearch

In this setup, Logstash listens on TCP port 4560 for incoming Studio logs. Then, it filters the logs based on timestamps and sends them to Elasticsearch using a predefined index name.

Logstash configuration files use Ruby-based syntax.

After creating the configuration file, start Logstash from the bin directory using the following command:

logstash.bat -f your-logstash-file.config

Once Logstash starts successfully, it begins consuming logs from Anypoint Studio.

Viewing Logs in Kibana

With Elasticsearch, Logstash, and Kibana running, restart the Mule application and generate logs again.

Next, open Kibana and navigate to index management. Create a new index pattern using the index name defined in the Logstash configuration.

Select @timestamp as the time field and complete the index pattern setup.

Afterward, go to the Discover section in Kibana. As a result, application logs appear in the Kibana interface, where filters and queries can be applied for detailed analysis.

Grafana Integration with Elasticsearch Logs

At this stage, ELK Grafana Integration allows logs stored in Elasticsearch to be visualized using Grafana dashboards.

Unzip the Grafana package and start the Grafana server by running grafana-server.exe from the bin directory.

Access the Grafana UI at:

http://localhost:3000

Log in using the default credentials admin/admin.

From the settings menu, navigate to Data Sources and add a new data source. Select Elasticsearch as the data source type.

Configure the data source using the Elasticsearch URL, the index name created earlier, and the appropriate Elasticsearch version. Then, save and test the connection to confirm successful integration.

Log Visualization Using Grafana Dashboards

After configuring the data source, navigate to the Explore section in Grafana. Select the Elasticsearch data source to view log activity in graphical form.

Additionally, Grafana supports custom dashboards. To create one, go to Dashboard Management, create a new dashboard, and add panels using the configured data source.

Each panel can represent log data in different formats such as time-series graphs, tables, histograms, or pie charts. Moreover, dashboards can include alerts and thresholds for proactive monitoring.

Conclusion

This walkthrough demonstrates how ELK Grafana Integration connects Anypoint Studio logs with Elasticsearch, Logstash, Kibana, and Grafana to deliver centralized logging and advanced visualization. By implementing this setup, teams gain real-time visibility into application behavior, which significantly improves debugging, monitoring, and operational awareness during development.

Moreover, this observability approach plays a critical role in MuleSoft application support by enabling faster issue identification, proactive monitoring, and better root-cause analysis. As a result, teams can maintain application stability and performance more effectively.

Although this guide focuses on Studio logs, similar principles apply to CloudHub environments. However, CloudHub requires additional configuration, such as disabling default logging or using CloudHub APIs to continuously retrieve logs. When implemented correctly, these techniques extend the same level of visibility to production workloads.

Overall, ELK Grafana Integration provides a scalable and flexible logging foundation that strengthens monitoring, troubleshooting, and long-term support for MuleSoft applications.