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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...