Dashboards & Visualizations

Create a new field for the Total from a addtotals command

johnward4
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

somesoni2
Revered Legend

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

johnward4
Communicator

alt text

EXAMPLE of my graph

0 Karma

somesoni2
Revered Legend

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
0 Karma

johnward4
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

somesoni2
Revered Legend

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

johnward4
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

johnward4
Communicator

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

0 Karma

somesoni2
Revered Legend

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
Get Updates on the Splunk Community!

This Week's Community Digest - Splunk Community Happenings [9.26.22]

Get the latest news and updates from the Splunk Community here! Upcoming User Group Events! &#x1f44f; Check ...

BSides Splunk 2022 - The Call for Papers is now Open!

TLDR; Main Site: https://bsidessplunk.com CFP Site: https://bsidessplunk.com/cfp CFP Opens: December 15th, ...

Sending Metrics to Splunk Enterprise With the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...