Splunk Search

How do I perform this awk command in Splunk?

Johnvey
Contributor

I would like to use the following cmd in splunk and I am getting errors.

egrep "Failed password" auth.log | awk '{print $13}' | sort | uniq -c | sort -rn | less

Is this possible?

(cross-posted from forums)

Tags (1)

cfield
Engager

try something along the lines of:

source=auth.log Failed password | rex "(?<src_ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" | stats count by src_ip | sort -count

this should produce a table of ip addresses and the count of the time they were in the logfile.

cfield
Engager

One caveat though, top will truncate the result set based on the limit= parameter, you would have to use limit=0 to get the same results.

0 Karma

Johnvey
Contributor

The clause "stats count by src_ip | sort -count" can be replaced with "top src_ip". The difference is that the "top" command will also add a "percent" field to the results.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...