Splunk Search

grouping multiple values of a field into one for charting

sathiyamoorthy
Explorer

Sample Data: Following is the result for a field which I'm tried to do chart for,

  • Linux - 10%
  • Unix - 10%
  • Firefox - 40%
  • Windows - 20%
  • IE - 20%

Instead of showing chart with above values, what should I do to view the following:

  • Open source - 60%
  • Commercial - 40%

Open source is the grouping of the values (Linux, Unix, Firefox), and commercial is Windows and IE. So how to group multiple values of a single field into one for charting, and how to give it some name? Any help is much appreciated, thanks.

1 Solution

Ayn
Legend

You could use eval and case to create groups like that. Let's say that your original field name is "system_id" and that you want to group values for this field and write that to the field "system_type". The, you'd do something like this:

... | eval system_type=case(system_id=="Linux" OR system_id=="Unix" OR system_id=="Firefox","Open source",system_id=="Windows" OR system_id=="IE","Commercial")

You can then use the system_type field in your chart.

View solution in original post

Ayn
Legend

You could use eval and case to create groups like that. Let's say that your original field name is "system_id" and that you want to group values for this field and write that to the field "system_type". The, you'd do something like this:

... | eval system_type=case(system_id=="Linux" OR system_id=="Unix" OR system_id=="Firefox","Open source",system_id=="Windows" OR system_id=="IE","Commercial")

You can then use the system_type field in your chart.

HattrickNZ
Motivator

can i use wild cards in the case statement? e.g. system_type=case(system_id=="Linux*" OR system_id=="Unix*")

0 Karma

mjm295
Path Finder

Did anyone get the wild cards working?

0 Karma

vsingla1
Communicator

Hi HattrickNZ and mjm295,
Wildcard does not work with case as expected. small trick is to use match within the case.
Check the answer here:
https://answers.splunk.com/answers/55524/eval-wildcards.html

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...