Splunk Search

Create 1-up number (1-to-n) field for each event and create field that combines the 1-up number and total count

williamcharlton
Path Finder

I have a search that returns a event count total and produces a table

... | eventstats count AS Total | Table foo, bar, Total

Search result is, e.g.,

foo | bar | Total
fx1 | bx1 | 3
fx2 | bx2 | 3
fx3 | bx3 | 3

My goal is to produce a 4th column named "EventNumber" that shows "E of N" when E is the ordinal position of the event in the search results and N is the total number of events in the search rsults

foo | bar | Total | EventNumber
fx1 | bx1 | 3 | 1 of 3
fx2 | bx2 | 3 | 2 of 3
fx3 | bx3 | 3 | 3 of 3

So, something like

... eventstats count AS Total | Table Cluster, OwnerNode, RoleName, Total | eval EventNumber = ?????." of ".Total

How do I create a 1-up number (1-to-n) field for each event and create a field that combines the 1-up number and total count of events?

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this

...| eventstats count AS Total 
| streamstats count as sno 
| eval EventNumber = sno." of ".Total
| Table Cluster, OwnerNode, RoleName, Total  EventNumber 

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try like this

...| eventstats count AS Total 
| streamstats count as sno 
| eval EventNumber = sno." of ".Total
| Table Cluster, OwnerNode, RoleName, Total  EventNumber 

williamcharlton
Path Finder
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...