Splunk Search

Grouping and counting by field

mjmcloughlin
Engager

Hey, I'm looking for a little advice.

I'm trying to produce a report showing how many events of a particular type (where the type is defined by a field) have happened grouped by a given time span... say 10 minutes.

So ideally it would look something like this

Time                |  HHProjection | Importer |
------------------------------------------------
2014-07-30T14:04:00 |           200 |      230 |

The closest I've got is something along these lines

* | where Stage = "HHProjection" or Stage="Importer" | eval formattedTime = strftime(_time, "%FT%H:%M:00") | stats count by Stage, formattedTime

But as you can tell this produces a line per Stage rather than a column per Stage.

As a complete beginner how would I go about writing this query?

Thanks in advance

Tags (1)
1 Solution

somesoni2
Revered Legend

Try this

Stage="HHProjection" or Stage="Importer" | timechart span=10m count by Stage

View solution in original post

somesoni2
Revered Legend

Try this

Stage="HHProjection" or Stage="Importer" | timechart span=10m count by Stage

mjmcloughlin
Engager

perfect, thanks!

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...