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
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 ...