Dashboards & Visualizations

Sum specific field value across all events

vivekkumarkk
Explorer

Hello,

 

I have a data stream getting populated every 5 minutes as below. There are 100s of features in the data.

Feature: Rectagle
Side: 4
User: A
Used:1
Time: 1/25/2021 5:00:00
Block:1

Feature: Rectagle
Side: 4
User: A
Used:1
Time: 1/25/2021 5:00:00
Block:2

Feature: square
Side: 4
User: B
Used:1
Time: 1/25/2021 5:05:00
Block:1

Feature: Square
Side: 4
User: B
Used:1
Time: 1/25/2021 5:05:00
Block:2

I need to sum the side for each side field along with the used column

Something as below.

Feature: Rectangle

Side: 8

used:2

Time: 1/25/2021 5:00:00

 

The problem I have is, I could not sum the side either it comes as total across all events (it can be 4 * number of times it access across the period I selected) or 4. I am searching for a period of last 24 hours.

I tried with this, but not giving right value.

| foreach feature*
[ eval subtotal = subtotal + 'side']
| stats max(subtotal) as TOTAL by _time

 

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you tried this?

... | stats sum(Side) as Side, sum(Used) as Used, first(Time) as Time by Feature
---
If this reply helps you, Karma would be appreciated.
0 Karma

vivekkumarkk
Explorer

My problem is, there are 2 block fields. The sum of Side should be only from 2 blocks. With the above query, its sums up all the side field.

The query must select field side for rectangle from each block for any user within the selected time and sum only the sum of sides (here it is 8   ) always.

It should not add another 4 if user B uses from Block 1 only. 

 

Thats why I tried with foreach.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If I understand correctly, you want different sums when the user changes.  That can be done with this modification.

... | stats sum(Side) as Side, first(Time) as Time by Feature, User
---
If this reply helps you, Karma would be appreciated.
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 ...