Splunk Search

Evaling a value based on the position of the event in stats ?

szabados
Communicator

I create a statistics table, which is sorted, and I use head 10 at the end, to display my results. What I want to do is, to add a new column with a number value, to show the position of the event.
something like this:

col1, col2, col3, position <---- thats what I want to add
value, value, value, 1
value, value, value, 2
value, value, value, 3
value, value, value, 4

How can I achieve this ?

0 Karma

somesoni2
Revered Legend

I believe you just want to add rownumber type of field. Try any one of below

Your current search which give your table | eval position=1 | accum position

OR

Your current search which give your table |streamstats count as position
0 Karma

badrinath_itrs
Communicator

Hi,

You can try something like this to populate the additional column .

your search ... | eval position="1,2,3,4," | makemv delim="," position | mvexpand position |  table col1, col2, col3, col4, position | head 4

You can change the position value and head command limit as per your requirement.

Hope it helps.

Thanks

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!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...