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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How To Validate Names Using Java
  • Datafaker Gen: Leveraging BigQuery Sink on Google Cloud Platform
  • Keep Your Application Secrets Secret
  • Application Assessment Questions for Migration Projects

Trending

  • Enhancing Security With ZTNA in Hybrid and Multi-Cloud Deployments
  • Automating Data Pipelines: Generating PySpark and SQL Jobs With LLMs in Cloudera
  • The Role of Functional Programming in Modern Software Development
  • AI-Based Threat Detection in Cloud Security
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Connect to Splunk Through Anypoint Studio in 10 Steps

How to Connect to Splunk Through Anypoint Studio in 10 Steps

A quick, step-by-step tutorial on how to create a Splunk account and connect it to Anypoint Studio using the cloud platform provided by Splunk.

By 
Rajat Vishwakarma user avatar
Rajat Vishwakarma
·
Feb. 16, 21 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
7.2K Views

Join the DZone community and get the full member experience.

Join For Free

1. Create a Splunk Account using the below link:

 https://www.splunk.com/

We can use either the cloud option or the download option. 

In this blog, we will be using the cloud option. An email will be triggered for verification and once verification is complete we will get our Splunk credentials like below:

Note: Save the Cloud-URL. We will be using this in the following steps.

2. Log in to the URL received via email:

Navigate to Settings -> Data Input 

3. Open the HTTP Event Collector and click 'New Token': 

4. Add the below config in the new token Config. Once we submit, we will get the token. Save the Token. We will be using this token in the next steps: 

5. Create one sample project.

Here we are using an HTTP Listener and create a sample payload. The same payload is being logged using the JSON logger.

Project flow:

Project XML: 

XML
 




xxxxxxxxxx
1
30


 
1
<?xml version="1.0" encoding="UTF-8"?>
2

          
3
<mule xmlns:json-logger="http://www.mulesoft.org/schema/mule/json-logger" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
4
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
5
    xmlns:sockets="http://www.mulesoft.org/schema/mule/sockets" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
6
http://www.mulesoft.org/schema/mule/sockets http://www.mulesoft.org/schema/mule/sockets/current/mule-sockets.xsd
7
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
8
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
9
http://www.mulesoft.org/schema/mule/json-logger http://www.mulesoft.org/schema/mule/json-logger/current/mule-json-logger.xsd">
10
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="2ebe7a73-f253-4265-a34b-06503551c083" >
11
        <http:listener-connection host="0.0.0.0" port="8081" />
12
    </http:listener-config>
13
    <json-logger:config name="JSON_Logger_Config" doc:name="JSON Logger Config" doc:id="2b1840f8-7446-42f3-b934-e75fa8f14f96" environment="dev" applicationName="Testing" applicationVersion="1.0.0"/>
14
    <flow name="splunk-flow" doc:id="3d2e9b4b-043f-42b4-8a53-60f278806e51" >
15
        <http:listener doc:id="03371965-d3d4-4b7c-bcd8-6cc65d3c6bea" doc:name="" path="/test" config-ref="HTTP_Listener_config"/>
16
        <ee:transform doc:name="sample Payload" doc:id="c3ab8cfe-5d72-47f6-9a5a-56ef49287c45" >
17
            <ee:message >
18
                <ee:set-payload ><![CDATA[%dw 2.0
19
output application/json
20
---
21
{
22
    
23
  "test": "Success"
24
}]]></ee:set-payload>
25
            </ee:message>
26
        </ee:transform>
27
        <json-logger:logger doc:name="Logger" doc:id="833a4e93-bcf0-4ad3-9d64-3c0b7ca35d40" config-ref="JSON_Logger_Config" message="testing"/>
28
    </flow>
29
</mule>
30

          



6. Update the POM to include the below dependency and repository:

XML
 




xxxxxxxxxx
1
15


 
1
       <dependency>
2
            <groupId>com.splunk.logging</groupId>
3
            <artifactId>splunk-library-javalogging</artifactId>
4
            <version>1.7.3</version>
5
        </dependency>
6
        <dependency>
7
            <groupId>org.apache.logging.log4j</groupId>
8
            <artifactId>log4j-core</artifactId>
9
            <version>2.10.0</version>
10
        </dependency>
11
        <dependency>
12
            <groupId>org.apache.logging.log4j</groupId>
13
            <artifactId>log4j-api</artifactId>
14
            <version>2.10.0</version>
15
        </dependency>


XML
 




x
36


 
1
<repositories>
2
          <repository>
3
                <id>Nexus</id>
4
                <name>Nexus Public Repository</name>
5
                <url>https://repository-master.mulesoft.org/nexus/content/groups/public/</url>
6
                <layout>default</layout>
7
          </repository>
8
          <repository>
9
            <id>anypoint-exchange</id>
10
            <name>Anypoint Exchange</name>
11
            <url>https://maven.anypoint.mulesoft.com/api/v1/maven</url>
12
            <layout>default</layout>
13
        </repository>
14
        <repository>
15
            <id>mulesoft-releases</id>
16
            <name>MuleSoft Releases Repository</name>
17
            <url>https://repository.mulesoft.org/releases/</url>
18
            <layout>default</layout>
19
        </repository>
20
        <repository> 
21
            <id>splunk-artifactory</id> 
22
            <name>Splunk Releases</name> 
23
            <url>https://splunk.jfrog.io/splunk/ext-releases-local</url>
24
        </repository>
25
    </repositories>
26
    <pluginRepositories>
27
        <pluginRepository>
28
            <id>mulesoft-releases</id>
29
            <name>mulesoft release repository</name>
30
            <layout>default</layout>
31
            <url>https://repository.mulesoft.org/releases/</url>
32
            <snapshots>
33
                <enabled>false</enabled>
34
            </snapshots>
35
        </pluginRepository>
36
    </pluginRepositories>



7. Copy the below Log4j file and replace the existing Log4j under src/main/resources.

Note: This is a minimum Log4j configuration to send the data to Splunk. Update the Your-CloudURL and Your-Token which you received in the previous steps.

XML
 




x


 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<Configuration status="INFO" name="cloudhub" packages="com.mulesoft.ch.logging.appender, com.splunk.logging ,org.apache.logging.log4j">
3
   <Appenders>
4
      <SplunkHttp name="splunk" url="<<Your-CloudURL>>:8088/" token="<<Your-Token>>" index="main" disableCertificateValidation="true">
5
         <PatternLayout pattern="%-5p %d [%t] [event: %X{correlationId}] %c: %m%n" />
6
      </SplunkHttp>
7
   </Appenders>
8
   <Loggers>
9
      <AsyncLogger name="org.mule.service.http" level="WARN" />
10
      <AsyncLogger name="org.mule.extension.http" level="WARN" />
11
      <!-- Mule logger -->
12
      <AsyncLogger name="org.mule.runtime.core.internal.processor.LoggerMessageProcessor" level="INFO" />
13
      <AsyncRoot level="INFO">
14
         <AppenderRef ref="splunk" />
15
     </AsyncRoot>
16
   </Loggers>
17
</Configuration>


8. Run the application and hit the below local URL:

9. Open the Search Reporting section in Splunk using the same cloud URL:

10. We can search the logs using the message part which we sent using the JSON logger:


XML Cloud Log4j Data (computing) JSON Payload (computing) application Dependency Repository (version control)

Opinions expressed by DZone contributors are their own.

Related

  • How To Validate Names Using Java
  • Datafaker Gen: Leveraging BigQuery Sink on Google Cloud Platform
  • Keep Your Application Secrets Secret
  • Application Assessment Questions for Migration Projects

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!