Splunk Search

How to write a search to compare two epoch times within a CSV file?

shaker_ali
Engager

I have an output.csv from one of the searches and it has two fields: join_date and login_date. Is there any way I can compare these to see if login_date is earlier than join_date?

Account_Name    join_date_epoch login_date
user1          1465549200        1465432131
user2          1465635600        1465432311
user3          1465722000        1465430101
user4          1465808400        1465433380
user5          1465894800        1465429387
user6          1465981200        1465402810
user7          1466067600        1465433332
user8          1466154000        1465433920
user9          1466240400        1465435287
user10        1466154000    

There can be empty login_date because the user might not have logged in.

Any help would be appreciated.

0 Karma

sundareshr
Legend

Try this

.... | where isnotnull(login_date) AND login_date<join_date    

*OR*

.... | fillnull value=0 login_date | where login_date>0 AND login_date<join_date
0 Karma

davebrooking
Contributor

I'd probably use an eval to assign a time of now to any 'empty' login_date. You maybe able to use a coalesce function, possibly something like

... | eval login_date=coalesce(login_date,now()) | ...

that should ensure the login_date is populated for all the events and then you should be able to use a where command to limit the results to just those you require

Dave

0 Karma

shaker_ali
Engager

Ok, i found a way to solve this.

| eval join_date_compare=if(join_date_epoch > login_date, "Yes","No")  | where join_date_compare="Yes"

Please let me know if you guys have any advise to improve this.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...