Splunk Search

Search earliest and latest within a field

mrdeterville
Explorer

Hi All;

I have list of events, which includes a field called reported_date, format is yyyy-mm-dd.

I'm trying to create a search that looks for reported_date within the last 15 months of current day. 

Is it possible to do an earliest and latest search within a specific field?

Note: _time does not align with the reported_date.

Any assistance would be greatly appreciated!

TIA

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Short answer is no. Events are timestamped by the _time field and earliest and latest applies to this field, not to some other field in the event. You would have to apply a time period (earliest and latest) to your search to cover enough of your events to find events where reported_date is between the times you are interested in.

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

In addition to what @ITWhisperer says, what is the physical significance of _time currently in your data?  Is there any reason why your ingestion should NOT use reported_date instead of whatever is used in current data?  That will make your requirement so much simpler to fulfill. (If this is a viable alternative, there could be other benefit, too.)

This said, Splunk can always search records where reported_date falls within the last 15 months.  Here, I will illustrate with the following caveat: reported_date is always earlier than or equal to _time.  There can be other strategies to search if this condition is not true but unless that is a problem in your case, the following method is simpler.

<your search criteria> earliest=-15mon
| where relative_time(now(), "-15mon") < strptime(reported_date, "%F")
``` "%F" -> "%Y-%m-%d" ```

 

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Short answer is no. Events are timestamped by the _time field and earliest and latest applies to this field, not to some other field in the event. You would have to apply a time period (earliest and latest) to your search to cover enough of your events to find events where reported_date is between the times you are interested in.

Get Updates on the Splunk Community!

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

[Puzzles] Solve, Learn, Repeat: Nested loops in Event Conversion

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Your Guide to Splunk Digital Experience Monitoring

A flawless digital experience isn't just an advantage, it's key to customer loyalty and business success. But ...