Splunk Search

Group results by field

zamkov
Explorer

I am trying to group a set of results by a field. I'd like to do this using a table, but don't think its possible. Similar questions use stat, but whenever a field wraps onto the next line, the fields of a single event no longer line up in one row.

My data:
jobid, created, msg, filename

Currently, I have jobid>300 | sort created | stats latest(created) as last list(created) list(msg) list(filename) by jobid | sort last | fields - last
But when msg wraps onto the next line, the msg's no longer line up with the correct timestamp.

ex. wrapped line

0 Karma

sundareshr
Legend

Try this

jobid>300 |streamstats latest(created) as last by jobid | table last, created, msg, filename
0 Karma

thirumalreddyb
Communicator

| stats latest(created) as last, list(msg), list(filename) by jobid, created | sort last | fields - last

This should solve your problem.

0 Karma

zamkov
Explorer

Actually this doesn't seem to work even without real-time search - the results are displayed by time and not grouped by jobid at all.

0 Karma

zamkov
Explorer

This is close, but when I use this in a real-time search, the results no longer stayed grouped by jobid. ie. if I get a message for jobid 100 then 200 then 100, it will be displayed
100 ....
200 ...
100 ...

The original search would display it as
200 ...
100 ...
100 ....

Is there a way to keep it grouped by jobid with real-time results?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

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, ...