Splunk Search

Retrieving latest timestamp from CSV file such that it is smaller than event time

andra_pietraru
Path Finder

Hello,

I am using lookups to get some metadata from a CSV file that also has timestamps.

How could I retrieve the latest (maximum) timestamp from the CSV such that it is smaller than the event time? Is there any command that can do that? I tried stats and max, but that only finds the maximum without taking into consideration the second condition.
Thanks in advance!

Tags (3)

richgalloway
SplunkTrust
SplunkTrust

No one command can do that. Filter first for smaller times then look for max. Something like ... | where csvTime < _time | stats max(csvTime) | ....

---
If this reply helps you, Karma would be appreciated.

andra_pietraru
Path Finder

Just to make it more clear: based on IP addresses I retrieve MAC addresses and timestamps from the CSV file. I will retrieve several timestamps for each IP address. What I want to achieve is to make a timechart where I can see the MAC addresses in time. So, for example, if I have 2 MAC address with timestamp 1st of April and then I have only one MAC address with timestamp 1st of May for IP "::1", I want to see that in the timechart. Hence, from 1st April to 1st May IP "::1" should have two MAC addresses and starting 1st of May only one MAC address.
Do you have any suggestions? Thanks

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Get the data from the CSV, but don't worry about smaller times. Let the bucketing feature of the timechart command handle that for you. Something like ... | timechart minspan=1mon count by MAC.

---
If this reply helps you, Karma would be appreciated.

andra_pietraru
Path Finder

If I choose a smaller time range, example: 29 April - 2 May, then I always see two MAC addresses. So, setting up minspan is not enough or am I missing something?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You may indeed be missing something, but I don't know what that would be. 😉

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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