DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • MuleSoft MCP and A2A in Production: What 17 Recipes Reveal
  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  • From AI Chaos to Control: Building Enterprise-Grade LLM Gateways With MuleSoft Anypoint
  • Revolutionizing Scaled Agile Frameworks with AI, MuleSoft, and AWS: An Insider’s Perspective

Trending

  • Good Data, Bad Metric: A Mutation Testing Pattern for Analytics Engineering
  • Prompt Injection Is Real, So I Built a Python Firewall for LLM Pipelines
  • How to Save Money Using Custom LLMs for Specific Tasks
  • Migrate a Hardcoded LangGraph Agent to LaunchDarkly AI Configs in 20 Minutes
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Publish Log From Naked Mulesoft Deployment to Graylog

Publish Log From Naked Mulesoft Deployment to Graylog

This article is a tutorial on how to perform a Naked deployment to a MuleSoft configuration in order to send a log to Graylog.

By 
Sadik Ali user avatar
Sadik Ali
·
Dec. 31, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
8.4K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

In this article, I discuss what Graylog is and how to perform a Naked deployment to a MuleSoft configuration in order to send a log to Graylog. 

MuleSoft Features

MuleSoft supports configuration and dependencies in log4j to publish logs to Graylog from CloudHub and Naked MuleSoft deployments.

Graylog (MuleSoft)

A basic condition is to find a way to promote the Mule application logs to a third-party logging platform like Graylog. This allows you to maintain the logs between redeployment in the event of a crash.

About Graylog

Once messages are being received, we can poke around and explore a bit. There are several pages available, though not all the pages may be visible to all users, depending on individual permissions. The following are a few brief descriptions of each page’s purpose and function.

  • Streams: Streams are a mechanism used to route messages into categories in real-time
  • Searches: Searches may be saved or visualized as dashboard widgets that may be added directly to dashboards from within the search screen.
  • DashBoards: Graylog Dashboards are visualizations or summaries of information contained in log events. Each dashboard is populated by one or more widgets.
  • Alerts: Alerts are composed of two related elements, alert conditions, and alert notifications. Alert conditions are tied to streams and may be based on the content of a field, the aggregated value of a field, or message count thresholds. An alert notification triggers when a condition is met, typically sending an email or HTTP call back to an analyst or another system.
  • Accepts messages from various input protocols GELF via HTTP/UDP/TCP, Syslog, etc.
  • Allow messages to stream Trigger user-defined alerts per currents Stores messages in Elastic Search for graphing Provides messages to distinct outputs based on streams Uses MongoDB to store metadata and alerts.
  • Graylog is a very flexible solution. It can be deployed in many different ways. For those who would like to do an initial lab evaluation of Graylog, we recommend starting with the virtual machine appliances.

Graylog Architect

Graylog architect graphic.

Naked Deployed MuleSoft Configuration to Send the Log to Graylog

  • MuleSoft application helps to customize log to transmit to custom appender defined in Log4j file. 
  • Following the same method, we can configure the MuleSoft logz.io custom library and dependencies in pom.xml and log4j file to publish logs to the Logz.io tool.

Below Configuration approach can be defined as below: 

  • The package needs to configure in the log4j file.
  • Appender need to define.
  • Dependencies need to define in pom.xml file.

The package needs to be configured in the log4j file as shown below.

XML
 




xxxxxxxxxx
1


 
1
 <Configuration status="debug" packages="biz.paluch.logging.gelf.log4j2">
2

          
3
   <AsyncRoot level="INFO">
4
            <AppenderRef ref="file" ></AppenderRef>
5
            <AppenderRef ref="gelf" ></AppenderRef>            
6
        </AsyncRoot>



Appender needs to define.

XML
 




xxxxxxxxxx
1
14


 
1
<Gelf name="gelf" host="udp:Host" port="PORT" version="1.0"
2
            extractStackTrace="true" filterStackTrace="true" mdcProfiling="true"
3
            includeFullMdc="true" maximumMessageSize="8192"
4
            originHost="my.host.name"            additionalFieldTypes="fieldName1=String,fieldName2=Double,fieldName3=Long"
5
            ignoreExceptions="true">
6
            <Field name="timestamp" pattern="%d{dd MMM yyyy HH:mm:ss,SSS}" />
7
            <Field name="level" pattern="%level" />
8
            <Field name="simpleClassName" pattern="%C{1}" />
9
            <Field name="className" pattern="%C" />
10
            <Field name="server" pattern="%host" />
11
            <Field name="server.fqdn" pattern="%host{fqdn}" />
12
        </Gelf>



POM dependencies added:

XML
 




xxxxxxxxxx
1


 
1
        <dependency>
2
            <groupId>biz.paluch.logging</groupId>
3
            <artifactId>logstash-gelf</artifactId>
4
            <version>1.14.1</version>
5
        </dependency>



Graylog Initial Configuration

  • Create a user in Graylog.
  • Configure Input configuration to allow receiving log/data from external application using UDP (GELP UDP Section).

Configure Input configuration screenshot.
MuleSoft Configuration in MuleSoft Application Flow

  • Below is the configuration in the logger component will be done to follow Graylog appender configure in Log4j file.

Configuration in the logger component screenshot.Test Request

Test request screenshot.Logs Can Be Verified in Graylog

Log verification in Graylog screenshot.

Sample GitHub Code

Video Explained.

MuleSoft

Published at DZone with permission of Sadik Ali. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • MuleSoft MCP and A2A in Production: What 17 Recipes Reveal
  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  • From AI Chaos to Control: Building Enterprise-Grade LLM Gateways With MuleSoft Anypoint
  • Revolutionizing Scaled Agile Frameworks with AI, MuleSoft, and AWS: An Insider’s Perspective

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook