Splunk Search

eval strftime search assistance

bzsplunk54
New Member

Hello,

I’m hoping for some suggestions for the process that I am trying to accomplish. I have a universal forwarder setup to ingest a _json file of which includes a complete network inventory. This inventory.json file is populated by GET processing from our ACS system. This process pulls in all active equipment and populates the .json file on a nightly basis. We do not purge the json file regularly as we want to be able to recall comparison data over time for number-based management processes. If a device is removed from the network or if the device is offline for some reason it still will be visible within the inventory.json file. Currently I am running the below and flagging a ‘last access’ element and putting that against the eval with strftime. This presents me with the devices that have been online over the past day and does not show if a device is currently offline or has been removed from the network as I only want current information, and this works for me.

earliest =-0d@d latest=now
| eval seen=strftime(last_access, "%T %F, %Z")

OBJECTIVE:
I need to be able to have the strftime review the last 5 days however only display one entry with that entry being the lastest. So if I am looking at this inventory.json file on Friday I also want to be shown the device if it was online Wednesday but currently not today.

Tags (3)
0 Karma

cmerriman
Super Champion

can't you just change the earliest to earliest=-5d@d to look at the last 5 days of data?
you can use a few evals to see if it was last seen today and other last seen dates

   | eval last_seen=strftime(last_access, "%T %F, %Z")
|eval last_seen_today=if(last_access>=relative_time(now(),"@d"),last_seen,null())
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...