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 (2)
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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...