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!

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...

What’s New in Splunk Cloud Platform 9.1.2308?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2308! Analysts can ...