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!

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...