Followers

Friday, May 8

How to add Serial Number in each line of your event

       How to add Serial Number in each line of your event




     There are many ways to achieve the above scenario :



1. Using "steamstats"   


      index="_internal" sourcetype=splunkd 
    | table log_level, splunk_server 
    | head 4
    | streamstats count | table count,log_level,splunk_server



countlog_levelsplunk_server
1                                    INFOXXXX
2                                   INFOXXXX
3                                   INFOXXXX
4                                   INFOXXXX






2. Using "accum"   


      index="_internal" sourcetype=splunkd 
    | table log_level, splunk_server 
    | head 4
    | eval Number=1 
    | accum Number
    | table Number,log_level,splunk_server


Numberlog_levelsplunk_server
1                                 INFOXXXX
2                                 INFOXXXX
3                                 INFOXXXX
4                                 INFOXXXX






Hope this has helped you in achieving the below requirement without fail :

How to add Serial Number in each line of your event


Happy Splunking !!