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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...