Splunk Search

How to compare to searches in different indexes?

mkelderm
Path Finder

How can I compare two or more source-types (each source-type has a unique index) with each other? Each source-type has errors, I want to count the number of errors on each source-type and compare them with each other over a period.

I thought:

(index=iplan AND sourcetype=iplan AND Error) | eval bron=1 | append [ search (index=web AND sourcetype=access-kim AND Error) | eval bron=2 ] | timechart count(bron) by bron | fields bron, count(bron)

But this is not working 😞

Tags (1)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Without having seen your actual log data, and making some assumptions regarding your desired output...do you relly need an append?

(index=iplan sourcetype=iplan) OR (index=web sourcetype=access-kim) Error | timechart count by sourcetype

You could further simplify by removing the index= statements IF both of those indexes are searched by default, and those sourcetypes are not present in other indexes also searched by default.

If this doesn't help, please supply some sample events, and a more detailed description of the output you want.

hope this helps,

Kristian

View solution in original post

0 Karma

kristian_kolb
Ultra Champion

Without having seen your actual log data, and making some assumptions regarding your desired output...do you relly need an append?

(index=iplan sourcetype=iplan) OR (index=web sourcetype=access-kim) Error | timechart count by sourcetype

You could further simplify by removing the index= statements IF both of those indexes are searched by default, and those sourcetypes are not present in other indexes also searched by default.

If this doesn't help, please supply some sample events, and a more detailed description of the output you want.

hope this helps,

Kristian

0 Karma

tgow
Splunk Employee
Splunk Employee

Without looking at your data you might be able to shorten this up a bit. Remember that just like Google, the Splunk search has an inherent boolean "AND" so you do not need to state it. Also if you are going to have an eval statement then the variables need to be unique.

index=iplan sourcetype=iplan Error | eval bron=1 | append [ search index=web sourcetype=access-kim  Error | eval bron2=2 ] | timechart count(bron) by bron2 | fields bron, count(bron2)
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...