Splunk Search

How to find out the record which has unique value

jianyu75074
New Member

I have records have 2 fields:
phone number result
1111 success
2222 success
2222 failed
3333 success
3333 failed
4444 failed

How to get the phone number which got failed ONLY. in this example, I want to get "4444"
if I search by result=failed, I got 2222,3333 and 4444. But I want to exclude 2222 and 3333 as they got "success"

is there any quick way to do that ? thanks!

Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @jianyu75074,
try this

| makeresults 
 | eval _raw=" number result
 1111 success
 2222 success
 2222 failed
 3333 success
 3333 failed
 4444 failed" 
 | multikv forceheader=1 
 | fields - linecount _raw _time
 | stats values(result) AS result dc(result) AS dc_result BY number
 | search result=failed AND dc_result=1

where the solution are the last two rows.

Ciao.
Giuseppe

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

... | stats values(result) AS results dc(result) AS result_count BY phone number
| where result_count="1" AND results="failed"
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jianyu75074,
try this

| makeresults 
 | eval _raw=" number result
 1111 success
 2222 success
 2222 failed
 3333 success
 3333 failed
 4444 failed" 
 | multikv forceheader=1 
 | fields - linecount _raw _time
 | stats values(result) AS result dc(result) AS dc_result BY number
 | search result=failed AND dc_result=1

where the solution are the last two rows.

Ciao.
Giuseppe

0 Karma

manjunathmeti
Champion

Try this:

| mvcombine result | search result!="*success*"

Sample query:

| makeresults 
| eval _raw=" number result
1111 success
2222 success
2222 failed
3333 success
3333 failed
4444 failed" 
| multikv forceheader=1 
| fields - linecount _raw _time 
| mvcombine result 
| search result!="*success*"
0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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