Splunk Search

How to find events which have a certain field which occurs more than once?

jesabs
Engager

I have some events which have a field which is named variable. So the event will be like..

field1="a" field2="b" variable="1" field3="d" variable="2" field4="f" variable="3"

Sometimes the variable field shows up 0 times, sometimes 1 time, and sometimes multiple times in an event. I have been trying to come up with a search that can return only the events which have it multiple times.

I do not care about the value of the variable field. I just want to find when the field is in an event more than once. Could anyone help me out?

Tags (3)
0 Karma
1 Solution

sundareshr
Legend

If the name of the field will always be "variable", you could try this

your base search | where mvcount(variable)>1 | ...

IIf the field has not been extracted, try this

your base search | rex max_match=0 "variable=\"(?<variable>\d+)\"" |  where mvcount(variable)>1

View solution in original post

sundareshr
Legend

If the name of the field will always be "variable", you could try this

your base search | where mvcount(variable)>1 | ...

IIf the field has not been extracted, try this

your base search | rex max_match=0 "variable=\"(?<variable>\d+)\"" |  where mvcount(variable)>1

jesabs
Engager

The second one worked. The first one did not work, it would always report 0 or 1. I think because only the first occurrence of a field is recognized if you have MV_ADD set to false in the splunk config. Having the rex overcomes this.

Thanks you!

0 Karma
Get Updates on the Splunk Community!

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...