Splunk Search

combine 3 search queries in which 2 of them are the result of the last one

robertspeckmann
Explorer

What i am trying to accomplish is the following;

I have 3 search queries. The first one displays a single value that gives me the sum of messages that a service of us recieved and accepted on the service adapter.
I also have a query that sums up the messages that got rejected on the service adapter.
My third query shows the value of the messages that have been recieved on a different service adapter.

Is it possible to create a panel in wich i can check if the first and second query combined have the same value als the last query?
I tried to combine the queries with a append of multisearch but i cannot seem to get the result I want.

first query:
index=foo sourcetype="foo:bw" barAdapter Operation=foo | stats distinct_count(ConversationID) as Total1

second query:
index=foo sourcetype="foo:bw" "barAdapter" Operation=foo FromParty=xxx | stats count as Total2

third query:
index=foo sourcetype="foo:bw" "Publishing to endpoint Queue" Operation=foo | stats count as Total3

Thank you in advance for any help.

0 Karma
1 Solution

dineshraj9
Builder

You can calculate multiple statistics together in a single search and combine the results in one search this way -

index=foo sourcetype="foo:bw" Operation=foo "barAdapter" | stats distinct_count(ConversationID) as Total1,count(eval(FromParty=xxx)) as Total2 | appendcols [ search index=foo sourcetype="foo:bw" Operation=foo "Publishing to endpoint Queue"  | stats count as Total3 ]

View solution in original post

0 Karma

dineshraj9
Builder

You can calculate multiple statistics together in a single search and combine the results in one search this way -

index=foo sourcetype="foo:bw" Operation=foo "barAdapter" | stats distinct_count(ConversationID) as Total1,count(eval(FromParty=xxx)) as Total2 | appendcols [ search index=foo sourcetype="foo:bw" Operation=foo "Publishing to endpoint Queue"  | stats count as Total3 ]
0 Karma

robertspeckmann
Explorer

Great i have solved it by your explanation dineshraj9! thank you

0 Karma

robertspeckmann
Explorer

This way, it won't work since the output of Total2 is different from the first query. I just scrambled some of the data in the queries since i cannot share the real names and input.

With the query above i get a total at Total1 en Total 3 but zero results on Total2

0 Karma

dineshraj9
Builder

If your base search for Total1 and Total2 is same index=foo sourcetype="foo:bw" Operation=foo "barAdapter", then you can calculate Total1 and Total2 in the same query.

For Total2 you just need to ensure that the field FromParty is created and it has the value for which you want to calculate the count.

Alternative way would be to combine 3 searches -

index=foo sourcetype="foo:bw" barAdapter Operation=foo | stats distinct_count(ConversationID) as Total1 | appendcols [ search index=foo sourcetype="foo:bw" "barAdapter" Operation=foo FromParty=xxx | stats count as Total2 ]  | appendcols [ search index=foo sourcetype="foo:bw" "Publishing to endpoint Queue" Operation=foo | stats count as Total3 ]
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...