Splunk Search

Repeat index and host time in tablerow

karunagaraprabh
Explorer

Hi, i need index time and host time to repeat for each data for host, printedA_epoch & printedb_epoch, how can i achieve it

karunagaraprabh_0-1592968527889.png

 

Thanks,

Karuna

 

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

If you have Splunk 8 (for mvmap) you can do this

| makeresults
| eval r=mvrange(1,15)
| mvexpand r
| eval printedA_epoch=now() - (random() % 604800)
| eval printedB_epoch=now() - (random() % 604800)
| eval indtime=now()
| eval host="XP03"
| stats values(printedA_epoch) as printedA_epoch values(printedB_epoch) as printedB_epoch by host indtime
| table host printedA_epoch printedB_epoch indtime
| eval comment="Your data is created up to here - so now duplicate host and indtime as required"
| eval h=mvrange(1,mvcount(printedA_epoch) + 1)
| eval host=mvmap(h,host), indtime=mvmap(h,indtime)
| fields - h comment

Hope this helps 

karunagaraprabh
Explorer

Thank you @bowesmana  but am using splunk 7.0.1 where  'mvmap'  function is not supported or undefined, could you please provide me an alternative command.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Try this

| makeresults
| eval r=mvrange(1,15)
| mvexpand r
| eval printedA_epoch=now() - (random() % 604800)
| eval printedB_epoch=now() - (random() % 604800)
| eval indtime=now()
| eval host="XP03"
| stats values(printedA_epoch) as printedA_epoch values(printedB_epoch) as printedB_epoch by host indtime
| table host printedA_epoch printedB_epoch indtime
| eval comment="Your data is created up to here - so now duplicate host and indtime as required"
| eval tmp=mvzip(printedA_epoch, printedB_epoch, ",")
| fields - printedA_epoch printedB_epoch comment
| mvexpand tmp
| rex field=tmp "(?<printedA_epoch>\d+),(?<printedB_epoch>\d+)"
| fields - tmp
| stats list(*) as *

karunagaraprabh
Explorer

Thanks for your valuable time

| stats list(*) as * it displays all my field in the indexed data i have to display only limited columns

CustomerjobId,printedA_epoch,printedB_epoch,indexdatetime

as i have to do difference of A and B epoc with indexedtime epoc 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Replace the list(*) as * with

list(a) as a list(b) as b list(c) as c 

for the columns you need

karunagaraprabh
Explorer

Hi @bowesmana , really appreciate your multiple solution, after implementing am getting Aepoch vales as 0000 instead of its value..

karunagaraprabh_0-1592986505291.png

 

Thanks,

Karuna

 

 

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...