Splunk Search

how to find differnce between epoch

karunagaraprabh
Explorer

When i try to find the difference between two epoc

1)find the days range i get blank values
2) and i need to filter only records where days =0

| eval printedA_epoch=strptime(printedtimestrampA,"%Y-%m-%dT%H:%M:%S.%Q"),printedB_epoch=strptime(printedtimestrampB,"%Y-%m-%dT%H:%M:%S.%Q")
| eval indextime =_indextime
| eval diffA=indextime-printedA_epoch, diffB=indextime-printedB_epoch
| eval daysA= round((diffA/86400),0) , daysB= round((diffB/86400),0)
| table host,printedA_epoch,printedB_epoch,indextime,diffA,diffB,daysA,daysB

karunagaraprabh_2-1592987307771.png

 

 

 

 

Labels (1)
0 Karma

rnowitzki
Builder

I just saw that you basically assked the question twice. 


https://community.splunk.com/t5/Splunk-Search/How-to-find-the-no-of-days-different-between-indexed-d...


You are on a good way with Giuseppe, so maybe you want to remove this duplicate.

--
Karma and/or Solution tagging appreciated.
0 Karma

rnowitzki
Builder

Hi @karunagaraprabh ,

Looking at your screenshot, it looks like printedA_epoch an printedA_epoch are MV (Multi Value) fields, is that correct?

So something in your SPL (that is not visible in your Screenshot) puts all the timestamps belonging to one host in a MV field. So the calculation does not work. You have to know/define which timestamp you want to calculate against the indextime, or (if you need to calculate against all) you have to change the SPL so that there is a line for each A and B timestamp pair.

We might need the full SPL and/or some sample data to help more detailed.


--
Karma and/or Solution tagging appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...

Splunk Developers: Construct Your Future at the .conf26 Builder Bar

Calling all Splunk architects, platform admins, and app developers: the site is open, and the blueprints are ...

Quick connection discovery mode for forwarders

When a Splunk forwarder loses connectivity to its indexers, it does not always reconnect immediately. In many ...