Dashboards & Visualizations

Create a new field for the Total from a addtotals command

Communicator

I'm trying to create a bar graph that displays the count(tickets) by group and then the TOTAL count of all tickets for the groups.

I'm currently using |addtotals to calculate the Total but I would like to create a new field to store that number. Right now I'm getting the Total showing under my Groups field. Ideally, I'd like to be able to use the new field for Total to show as a different color or overlay. I can't quite find what I'm looking for and it seems like others have asked about this.

index=test Groups=* 
| dedup Tickets
| chart count(Tickets) by Groups
| rename count(Tickets) as Tickets
| sort - Tickets
| addcoltotals Tickets
| fillnull value="TOTAL"
0 Karma
1 Solution

SplunkTrust
SplunkTrust

Try like this. This will give field TOTAL as separate bar (in different color). You can also use it as overlay field.

index=test Groups=* 
 | dedup Tickets
 | chart count(Tickets) by Groups
 | rename count(Tickets) as Tickets
 | sort - Tickets
 | eventstats sum(Tickets) as TOTAL

View solution in original post

0 Karma

Communicator

alt text

EXAMPLE of my graph

0 Karma

SplunkTrust
SplunkTrust

Try like this. This will give field TOTAL as separate bar (in different color). You can also use it as overlay field.

index=test Groups=* 
 | dedup Tickets
 | chart count(Tickets) by Groups
 | rename count(Tickets) as Tickets
 | sort - Tickets
 | eventstats sum(Tickets) as TOTAL

View solution in original post

0 Karma

Communicator

That gives me the total tickets for each Group as a separate colored bar but what I'm looking for is the total of all groups in one separate column called Total.

That's why addtotals came to mind as a way to calculate the number I need but I'm having trouble creating a new field with the Total.

0 Karma

SplunkTrust
SplunkTrust

It is going to give you total of all groups. Since we're adding a new column for total it comes with all group but its actually sum of all. Having it as additional column will allow you to do chart overlay.

0 Karma

Communicator

Thank you. In the new field 'TOTAL' I see the correct calculation but instead of it writting once, I see the total calculation written over and over for each line that I have a group. This will confuse my users when they hover over the overlay and it still says

GroupName : Infrastructure
TOTAL : 9,090 <----- that's the right number but is there a way to remove the GroupName in this new field?

0 Karma

Communicator

@somesoni2 any ideas on how to remove the groupname from my total overlay?

0 Karma

SplunkTrust
SplunkTrust

Since it's overlay field, it'll be available for all group names (all rows). What you can do is to rename the field TOTAL to say "ALL Group's Total" so that it's less confusing.

0 Karma