Splunk Search

can we display the S.no field along with my table command ?

rakesh_498115
Motivator

Hi..

is it possible a field called SNO along with my search search results , which will old the serial no of events .i.e 0 ,1 ,2 ,,and so on..

i.e i need the following when i use the table command ..

SNO Field Field
0 data data
1 data data
2 data data
....
.
.
.

and so on..

how can i do this ??

please help..

Tags (1)
0 Karma
1 Solution

Gilberto_Castil
Splunk Employee
Splunk Employee

Hello,

If the field SNO does not exist, you can dynamically create it during search time. The Splunk command you are looking for here is accum -which increments a field value by one.

There is one small catch here, the command will not begin to increment if the field value starts with a zero. Nonetheless, there is a way around it. Here is a quick search that should help:

index=blah sourcetype=blah blah | eval SNO=1 | accum SNO | eval SNO=SNO-1 | table SNO Field1 Field2

It should be noted, however, that Splunk will show row numbers in a table by default. The numbering will begin at one (1).

View solution in original post

Gilberto_Castil
Splunk Employee
Splunk Employee

Hello,

If the field SNO does not exist, you can dynamically create it during search time. The Splunk command you are looking for here is accum -which increments a field value by one.

There is one small catch here, the command will not begin to increment if the field value starts with a zero. Nonetheless, there is a way around it. Here is a quick search that should help:

index=blah sourcetype=blah blah | eval SNO=1 | accum SNO | eval SNO=SNO-1 | table SNO Field1 Field2

It should be noted, however, that Splunk will show row numbers in a table by default. The numbering will begin at one (1).

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!

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

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