Splunk Search

How to get intersection of two sets ?

Sid_kum
Explorer

Hello folks,

Thanks to visit my question.

Users are getting two kinds of errors say A and B one at a time. Both cannot happen simultaneously. I want to get no of users facing both types of error.

Can anyone please suggest any possible query to get this data ?

Thanks in advance.

Labels (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Sid_kum,

to do this you have to identify rules of errors, so if

  • Err_A is when there's the string "There's an error"
  • Err_B is when there's the string "There's a second error"

You have to create a search like this:

index=your_index ("There's an error" OR "There's a second error")
| eval type=if(searchmatch("There's an error"),"A","B")
| stats dc(type) AS dc_type count(eval(type="A")) AS Err_A count(eval(type="B")) AS Err_B BY user
| where dc_type>1

 Ciao.

Giuseppe

Sid_kum
Explorer

Thank you so @gcusello for you quick response.

So basically, I have my field  error_type which can be error_type="There's an error" OR error_type="There's a second error" and I also have user_guid as splunk data  to fill when it matches. Now I have to get those user_guid who have faced both the kinds of error.

 

 

Thanks!

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Sid_kum,

in this case it's easier:

index=your_index (error_type="There's an error" OR error_type="There's a second error")
| stats dc(error_type) AS dc_error_type count(eval(error_type="There's an error")) AS Err_A count(eval(type="B")) AS Err_B BY user_guid
| where dc_error_type>1

Ciao.

Giuseppe

Sid_kum
Explorer

@gcusello thank you!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Sid_kum,

good for You, see next time!

If this answer solves your need, please, accept it for the other people of Community.

Ciao and happy splunking.

Giuseppe.

P.S.: Karma Points are appreciated 😉

0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...