Splunk Search

How to get the result set of the last sample without using head search command

lpolo
Motivator

Hi,

Any idea how to get the result set of the last sample without using head. Let's say we have a summary index with the following log set:

time_1 G=1 orig_host=a
time_1 G=1 orig_host=b
time_1 G=3 orig_host=c

time_2 G=3 orig_host=a
time_2 G=2 orig_host=b
time_2 G=3 orig_host=c

Using the search command "head" I can get my last sample if I know the number of logs per sample. For example:

sourcetype=x|head 3|table _time orig_Host G

How can I get the same result set without using the head search command?

Thanks,
Lp

Tags (2)
0 Karma

sdaniels
Splunk Employee
Splunk Employee

I think you could probably modify the following answer:

http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source

Just change to | metadata type=hosts since you want to look up data based on a host.

0 Karma

lpolo
Motivator

I modified the question to clarify the scenario. I tried the example you sent me before I could not make it work. Any idea.

Lp

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...