Splunk Search

How to handle streamstats / delta assigning a 'zero' to the first row?

AlexBryant
Path Finder

My query is returning the total number of bytes received by various IP addresses at different points in epoch time. I'm using a combination of sort, streamstats, and delta to show how many ADDITIONAL bytes have been received since the last record, for a given IP address. So the data for a given IP address would be:

epoch_time; IP_address; delta_bytes_received
1000; 192.168.100.1; 0
1005; 192.168.100.1; 600
1008; 192.168.100.1; 70
1018; 192.168.100.1; 0
1021; 192.168.100.1; 223

The problem is that for each IP address's group of records, the delta for the first record shows up as zero since there is no previous record to 'delta' against. So when I run avg() and stdev() on the deltas (which is the end goal), there's always an unnecessary zero in the mix that skews the statistics. I tried assigning all zero-value deltas to 'null', but not only does that remove some valid 'zero' entries (like row number 4 above), the statistics are still generated based on the number of rows received, whether null or not, again skewing the results.

Is there a way for me to remove the first record for each IP address?

Tags (3)
0 Karma
1 Solution

jplumsdaine22
Influencer

Do something like | streamstats count as remove_me by ip | where NOT remove_me=1 before doing you calculations - that will remove the first instance of each ip

View solution in original post

jplumsdaine22
Influencer

Do something like | streamstats count as remove_me by ip | where NOT remove_me=1 before doing you calculations - that will remove the first instance of each ip

AlexBryant
Path Finder

Simple and works perfectly - thanks!

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...