Monitoring Splunk

Quick and Dirty Keyword Search

stakor
Path Finder

I know that this can be done with a lookup, but I was wondering if there was a quick and dirty way to search through web traffic for like three keywords. For example:

bad1
bad2
bad3

I would like to break the keywords into counts. Normally you would do count by fieldName.

Is there a way to do this in SPL, and not have to create a lookup table for each time you go hunting for something? This would probably be used once or twice per set of keywords - that is why I am not trying to do a saved lookup.

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try something like this

your base search bad1 OR bad2 OR bad3 
| eval keyword=case(searchmatch("bad1"),"bad1",searchmatch("bad2"),"bad2",searchmatch("bad3"),"bad3")
| stats count by keyword

OR

your base search bad1 OR bad2 OR bad3 
| rex max_match=0 "(?<keyword>(bad1|bad2|bad3)"
| stats count by keyword

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try something like this

your base search bad1 OR bad2 OR bad3 
| eval keyword=case(searchmatch("bad1"),"bad1",searchmatch("bad2"),"bad2",searchmatch("bad3"),"bad3")
| stats count by keyword

OR

your base search bad1 OR bad2 OR bad3 
| rex max_match=0 "(?<keyword>(bad1|bad2|bad3)"
| stats count by keyword
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...