Splunk Search

Help with splunk query, searchmatch finding false positives

hamishcross
Engager

Hey All,

Very new to using splunk and love the power of dashboards.

I'm executing the following

index=my_app ("C4C Auth Scenario")| stats count(eval(searchmatch("C4C Auth Scenario 1"))) as "S1", count(eval(searchmatch("C4C Auth Scenario 2"))) as "S2", count(eval(searchmatch("C4C Auth Scenario 3"))) as "S3", count(eval(searchmatch("C4C Auth Scenario 4Y"))) as "S4Y", count(eval(searchmatch("C4C Auth Scenario 4N"))) as "S4N", count(eval(searchmatch("C4C Auth Scenario 5"))) as "S5", count(eval(searchmatch("C4C Auth Scenario 6"))) as "S6" | untable blank Reason Count | table Reason Count

And I'm finding that S6 is returning false positives.

If I execute index=my_app "C4C Auth Scenario 6" no results are returned.

Yet if I execute the full query above, it returns multiple rows in the count

What would the cause of this be, and how do I go about ensuring it doesn't occur.

I'm looking to create a dashboard based on the occurrence of logging events.

Any help would be greatly appreciated.

0 Karma
1 Solution

FrankVl
Ultra Champion

I don't have an immediate answer for the difference in search results and the 'false positives' you experienced. Are you sure both searches were ran over the same time window?

Anyway, I would solve this by extracting the scenario 'number' into a field and then doing a stats by that field.

For example (you want to implement this with automatic field extractions in the end, so you don't need the line with the rex command anymore):

index=my_app ("C4C Auth Scenario")
| rex "C4C Auth Scenario (?<Reason>\w+)"
| stats count by Reason

View solution in original post

FrankVl
Ultra Champion

I don't have an immediate answer for the difference in search results and the 'false positives' you experienced. Are you sure both searches were ran over the same time window?

Anyway, I would solve this by extracting the scenario 'number' into a field and then doing a stats by that field.

For example (you want to implement this with automatic field extractions in the end, so you don't need the line with the rex command anymore):

index=my_app ("C4C Auth Scenario")
| rex "C4C Auth Scenario (?<Reason>\w+)"
| stats count by Reason

hamishcross
Engager

Thanks mate, that worked pretty well. Only thing I would say is I had to remove the "index=my_app" after rex to make it work. Was this in error or have I made a mistake?

0 Karma

FrankVl
Ultra Champion

Oh, yeah, copy paste mistake. Let me update it to prevent confusion if someone else reads this in the future 🙂

0 Karma

hamishcross
Engager

Awesome! For newbies like me, if it doesn't work, finding the problem can be really problematic. So really good to ensure the examples work. Thanks again

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...