Splunk Search

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

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 logindate is earlier than joindate?

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

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

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

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