Splunk Search

Splunk Other category when group by

msrama5
Explorer

Hi, I have saved search below Queryone and want to classify anything not falling under regx pattern for APIFamily in "URI "(?[/\w.]+/v\d+)/" " to classify as other category in search query 2, how can this be done in query 2 ?

Saved Search Queryone -
search environment=test
index=iis* NOT "GET / - 80" NOT "GET / - 443" NOT "/ping*" NOT "swagger"
|eval URI=lower(cs_uri_stem)
|rex field=URI "(?[/\w.]+/v\d+)/"
|regex APIFamily != "/content/v\d"
|regex APIFamily != "/appsettings/v\d"
|regex APIFamily != "/passbook/v\d"
| rex field=URI mode=sed "s/[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}/USER_ID/g"
| rex field=URI mode=sed "s/\/[0-9]+\/xid$/\/XID\/xid/g"
| rex field=URI mode=sed "s/{.*}/USER_ID/g"
| rex field=URI mode=sed "s/\/$//g"

Search Query 2 on QueryOne
| savedsearch QueryOne
| search *
| stats count as total, count(eval(sc_status>304)) as errors, count(eval(sc_status<304)) as pass by APIFamily
| eval error%=(errors/total)*100
| eval pass%=(pass/total)*100
| sort -total

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

It's not necessary (and generally discouraged) to post the same question 4 times.

Try this Query 2. It populates empty APIFamily fields with "OTHER".

| savedsearch FirstQuery
| search *
| fillnull value="OTHER" APIFamily
| stats count as total, count(eval(sc_status>304)) as errors, count(eval(sc_status<304)) as pass by APIFamily
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It's not necessary (and generally discouraged) to post the same question 4 times.

Try this Query 2. It populates empty APIFamily fields with "OTHER".

| savedsearch FirstQuery
| search *
| fillnull value="OTHER" APIFamily
| stats count as total, count(eval(sc_status>304)) as errors, count(eval(sc_status<304)) as pass by APIFamily
---
If this reply helps you, Karma would be appreciated.
0 Karma

msrama5
Explorer

that works, thanks

0 Karma

msrama5
Explorer

Reposting simplified query below, since no answers yet, I have saved search below FirstQuery and want to classify anything not falling under regx pattern for APIFamily in "URI "(?APIFamily[/\w.]+/v\d+)/" " to classify as other category in search query 2, how can this be done in query 2 ?

FirstQuery -
search environment=test
index=iis* NOT "GET / - 80" NOT "GET / - 443" NOT "/ping*" NOT "swagger"
|eval URI=lower(cs_uri_stem)
|rex field=URI "(?APIFamily[/\w.]+/v\d+)/"

Search Query 2 on FirstQuery
| savedsearch FirstQuery
| search *
| stats count as total, count(eval(sc_status>304)) as errors, count(eval(sc_status<304)) as pass by APIFamily

0 Karma

msrama5
Explorer

To make it simpler I have simplified the 2 queries

Saved Search Queryone -
search environment=test
index=iis* NOT "GET / - 80" NOT "GET / - 443" NOT "/ping*" NOT "swagger"
|eval URI=lower(cs_uri_stem)
|rex field=URI "(?[/\w.]+/v\d+)/"
| rex field=URI mode=sed "s/[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}/USER_ID/g"

Search Query 2 on QueryOne
| savedsearch QueryOne
| search *
| stats count as total, count(eval(sc_status>304)) as errors, count(eval(sc_status<304)) as pass by APIFamily

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...