Splunk Search

Combine / Add rows in the search results using a wildcard

veerappan
New Member

I am beginner to Splunk and could you please help me with the following scenario. I have a search that will display a pie chart of the computer count.

Now I would like to combine the search results with a wild card search

Search I use : mySearch here | stats dc(COMPUTER) by OS

alt text

Thanks in advance.

Labels (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@veerappan

Can you please try this?

YOUR_SEARCH | eval OS=case(like(lower(OS),"windows%"),"Windows",like(lower(OS),"mac%"),"Mac",1=1,OS) | stats sum("Computer Count") as "Computer Count" by OS

My Sample Search:

| makeresults | eval OS="Windows 7", "Computer Count"=50 | append [| makeresults | eval OS="Windows Server", "Computer Count"=25] | append [| makeresults | eval OS="Mac x", "Computer Count"=20]  | append [| makeresults | eval OS="Mac y", "Computer Count"=25]  | append [| makeresults | eval OS="Ubuntu", "Computer Count"=30] 
| eval OS=case(like(lower(OS),"windows%"),"Windows",like(lower(OS),"mac%"),"Mac",1=1,OS) | stats sum("Computer Count") as "Computer Count" by OS

Thanks

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@veerappan

Can you please try this?

YOUR_SEARCH | eval OS=case(like(lower(OS),"windows%"),"Windows",like(lower(OS),"mac%"),"Mac",1=1,OS) | stats sum("Computer Count") as "Computer Count" by OS

My Sample Search:

| makeresults | eval OS="Windows 7", "Computer Count"=50 | append [| makeresults | eval OS="Windows Server", "Computer Count"=25] | append [| makeresults | eval OS="Mac x", "Computer Count"=20]  | append [| makeresults | eval OS="Mac y", "Computer Count"=25]  | append [| makeresults | eval OS="Ubuntu", "Computer Count"=30] 
| eval OS=case(like(lower(OS),"windows%"),"Windows",like(lower(OS),"mac%"),"Mac",1=1,OS) | stats sum("Computer Count") as "Computer Count" by OS

Thanks

0 Karma

veerappan
New Member

@kamlesh_vaghela Thanks a lot it works 🙂

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 ...