Splunk Search

How can I get a count of words in an event?

daniel333
Builder

All,

Weird search. How can I get a count of words in an event?

e.g.
_raw = "Hello world. Hello state. Hello France"

outputs -
Hello = 3
world = 1
state = 1
France = 1

Tags (2)
0 Karma
1 Solution

sundareshr
Legend

Try this

... | rex max_match=0 "(?<words>\w+)" | mvexpand words | stats count by words

View solution in original post

0 Karma

sundareshr
Legend

Try this

... | rex max_match=0 "(?<words>\w+)" | mvexpand words | stats count by words
0 Karma

daniel333
Builder

How does max_match=0 work?

0 Karma

sundareshr
Legend

By default rex command will only get the first instance. max_match Controls the number of times the regex is matched. It will match all (max_match=0) instances put the values in a multivalue field.

http://docs.splunk.com/Documentation/Splunk/6.0.5/SearchReference/Rex

Get Updates on the Splunk Community!

Splunk Classroom Chronicles: Training Tales and Testimonials (Episode 3)

Welcome back to Splunk Classroom Chronicles, our ongoing blog series that pulls back the curtain on Splunk ...

Operationalizing TDIR: Building a More Resilient, Scalable SOC

Optimizing SOC workflows with a unified, risk-based approach to Threat Detection, Investigation, and Response ...

Almost Too Eventful Assurance: Part 1

Modern IT and Network teams still struggle with too many alerts and isolating issues before they are notified. ...