Splunk Search

How to group some of field value into new fields value?

syazwani
Path Finder

Hi peeps,

Need help to do some query. Basically I'm trying to group some of field value in the 'Category' field into new fields call 'newCategory'. Below are the sample of data:

syazwani_0-1668417552002.png

The newCategory field will have the new count for each of the new field value (such as Anonymizers, Gambling, Malicious Site).

Please help. 

Thank you.

 

Labels (4)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

This depends a lot on when you want this transformation.  If you want to see transformation before stats, it will depends on data characteristics.  Now, assuming you only want the transformation after | stats count by category, you can do

| eval newCategory = case(category IN ("Anonymizers", "Anonymizing Utilities", "Anonymizing Utilities, Internet Services"), "Anonymizers", category LIKE "Gambling%", "Gambling", category LIKE "Malicious Sites%", "Malicious Sites", true(), "Undef")

 

View solution in original post

Tags (1)

syazwani
Path Finder

Hi @yuanliu , thanks for reply. This solution worked. I try to do 

0 Karma

yuanliu
SplunkTrust
SplunkTrust

This depends a lot on when you want this transformation.  If you want to see transformation before stats, it will depends on data characteristics.  Now, assuming you only want the transformation after | stats count by category, you can do

| eval newCategory = case(category IN ("Anonymizers", "Anonymizing Utilities", "Anonymizing Utilities, Internet Services"), "Anonymizers", category LIKE "Gambling%", "Gambling", category LIKE "Malicious Sites%", "Malicious Sites", true(), "Undef")

 

Tags (1)
Get Updates on the Splunk Community!

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...

Observability protocols to know about

Observability protocols define the specifications or formats for collecting, encoding, transporting, and ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...