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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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

  • Android Application Security: Android Application Architecture
  • Git Blame Isn’t Enough: Building Verifiable Provenance for AI-Generated Code
  • The Five Stages of AI Adoption: A Practical Maturity Model for Software Teams
  • Multi-Agent Orchestration on AWS With AgentCore Runtime and A2A

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Feb. 16, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
7.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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