Splunk Search

How to sum of two result of appending subsearch in Total

Manasi25
Explorer

Hi,

I have two OUTPUT as " IA" and "IB" in one chart by appending sub search.

I want addcoltotals of sum of "IA" and "IB"

My input -

source type = router  routingKey=routingA OR routingKey=routingB

| stats sum(count) as count, avg(percent) as percent

| eval routingKey = "IA"
| append [ search routingKey=routingAA OR routingBB

| stats sum(count) as count, avg(percent) as percent

|eval routingKey = "IB" ]

| addcoltotals labelfield= routingKey label= “Total”

| table routingKey, count, percent

Result should be - 

 

routingKey   count   percent

IA                        50           50%

IB                         50           50%

Total                    ?               ?

Also, when i m searching result, its saying parsing job while giving output.

Do append command parsing my output? Is there any other command i can use instead of append.

 

Labels (1)
0 Karma
1 Solution

Nisha18789
Builder

Hi @Manasi25 , please use

| stats sum(count) as count, avg(percent) as percent | eval routingKey = "IA"

| append [ search routingKey=routingAA OR routingBB

| stats sum(count) as count, avg(percent) as percent |eval routingKey = "IB" ]

| addcoltotals labelfield=routingKey label=Total

| table routingKey, count, percent

View solution in original post

Nisha18789
Builder

Hi @Manasi25 , what is the issue you are facing, as your query seems alright? Are you getting different result than what is expected or not getting any results at all? Also, I believe count and percent are existing fields in your logs, is that so?

0 Karma

Manasi25
Explorer

the query - | addcoltotals labelfield= routingKey label= “Total” not resulting Output as below--

Total ?   ?

Yes, count and percent are existing fields in my logs.

I need output in a table as below. Total of count and percentage of "IA" and "IB" in last row.

routingKey count percent

IA                  50            50%

IB                  50             50%

Total            ?                   ?

 

I m getting only this -

IA           50         50%

IB           50         50%

I have mentions field values as well.here is my query --

source type = router routingKey=routingA OR routingKey=routingB

| stats sum(count) as count, avg(percent) as percent | eval routingKey = "IA"

| append [ search routingKey=routingAA OR routingBB

| stats sum(count) as count, avg(percent) as percent |eval routingKey = "IB" ]

| addcoltotals labelfield= routingKey label= “Total”

| table routingKey, count, percent

0 Karma

Nisha18789
Builder

Hi @Manasi25 , please use

| stats sum(count) as count, avg(percent) as percent | eval routingKey = "IA"

| append [ search routingKey=routingAA OR routingBB

| stats sum(count) as count, avg(percent) as percent |eval routingKey = "IB" ]

| addcoltotals labelfield=routingKey label=Total

| table routingKey, count, percent

Manasi25
Explorer

Thanks ! Its worked. 

I m using append query multiple times for different searches for same index.

Its parsing my job. Please advise solution.

 

Manasi25_0-1598176730143.png

 

0 Karma
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...