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

  • 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

  • A Guide to Container Runtimes
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • Internal Developer Portals: Modern DevOps's Missing Piece
  • Unlocking AI Coding Assistants Part 2: Generating Code
  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

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
  • [email protected]

Let's be friends:

OSZAR »