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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...