Splunk Search

How to show XX lines per sourcetype per host

a212830
Champion

Hi,

I want to look at the format for a number of hosts that are using the same sourcetype (I suspect that the format is different per host). Is there a way to do that?

Something like:

Host 1 - event 1
Host 1 - event 2
Host 1 - event 3...

Host 2 - event 1
Host 2 - event 2
Host 2 - event 3...

Tags (2)
0 Karma

gschmitz
Path Finder

sourcetype=foo (host=Host1 OR host=Host2) |table host, _raw ?

gschmitz
Path Finder

Hence my question mark. The answer I agve was a bit too obvious, so I already figured I was missing some detail.
I haven't tried it, but what would top 3 _time by host do? Since every time is probably unique, it should just take the first ones, right?

head unfortunately doesn't have a by clause.

0 Karma

a212830
Champion

Sorry, thought my example was pretty obvious. Apparently not. I'll try this and see what I get.

Thanks.

0 Karma

jkat54
SplunkTrust
SplunkTrust

You may also be interested in punct for this analysis

sourcetype=foo host=Host1 | head 10 | table host, punct| append [search sourcetype=foo host=Host2 | head 10 | table host, punct]

0 Karma

jkat54
SplunkTrust
SplunkTrust

gschmitz was correct, you can't tell him he's not because you didnt give him the correct requirements in your question. To limit the number of events per host use gschmitz answer but add a head. To do so will require two searches. Since we need two searches, we'll use the append command. With the append command, there will be no need to sort by host.

sourcetype=foo host=Host1 | head 10 | table host, _raw | append [search sourcetype=foo host=Host2 | head 10 | table host, _raw ]

a212830
Champion

That won't do it - I want to limit the number of events per host, and then display them in host and then time order. Not sure if it's even possible..

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...