Splunk Search

Creating a column for each field in a count

tpowell12
Explorer

I have a search for failed login attempts and am running a count based on EventCodes per host.

("EventCode=4625" OR "EventCode=529" OR "EventCode=530" OR "EventCode=531" OR "EventCode=532" OR "EventCode=533" OR "EventCode=534" OR "EventCode=535" OR "EventCode=536" OR "EventCode=537" OR "EventCode=539") | stats count by host, EventCode

host       EventCode    count  
host1        4625         3  
host1        529          6 
host2        529          3 
host3        529          6 
host3        4625         1 

Instead of listing each host multiple times for each EventCode, how can I have the host listed once with each EventCode in its own column as I have below.

host        529         4625
host1        6            3
host2        3
host3        6            1
0 Karma
1 Solution

dmaislin_splunk
Splunk Employee
Splunk Employee

Like this:

("EventCode=4625" OR "EventCode=529" OR "EventCode=530" OR "EventCode=531" OR "EventCode=532" OR "EventCode=533" OR "EventCode=534" OR "EventCode=535" OR "EventCode=536" OR "EventCode=537" OR "EventCode=539") | chart count(EventCode) over host by EventCode

View solution in original post

0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

Like this:

("EventCode=4625" OR "EventCode=529" OR "EventCode=530" OR "EventCode=531" OR "EventCode=532" OR "EventCode=533" OR "EventCode=534" OR "EventCode=535" OR "EventCode=536" OR "EventCode=537" OR "EventCode=539") | chart count(EventCode) over host by EventCode
0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

Good point Gilberto! And a big timesaver. You could download that app and then all the lookups would work assuming the field names for the lookup match to the field names he is using. An easy fix either way.

0 Karma

Gilberto_Castil
Splunk Employee
Splunk Employee

There is also an eventcode lookup in Splunkbase. Download it here: http://splunk-base.splunk.com/apps/22357/windows-event-codes-lookup.

0 Karma

dmaislin_splunk
Splunk Employee
Splunk Employee

What you want to do is create a lookup table with Splunk and then you can do:

chart count(EventCode) over host by EventCodeDescription

Have you done a lookup table yet? If you are happy with my answer, please accept it.

0 Karma

tpowell12
Explorer

Thanks for the quick response. Yeah, that solves it. Now from here, can I alias each of the EventCodes in the chart with something that I can understand rather than having the code number displayed?

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!

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...

Turn Cisco Telemetry Into Action with Cisco Data Fabric, powered by the Splunk ...

The surge in machine data is already hitting enterprise budgets, and the agentic era will only intensify it. ...

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...