Splunk Search

How to extract specific field values from Splunk query?

CuriousSplunky
Loves-to-Learn Lots
Hello,
My Splunk query returns the marks of students in the below format.
 
User                Subject                 Grade
John                Physics                 D
                          Science                A
                          Math                      B
                          Social                    C
                          History                 D
Mark                Physics               A
                          Social                   B
                          History                 C
Sam                 Math                     C
                          Social                   D
                          History                A
 
How can I filter the query to show only marks for Physics and Social? Somewhat like the below.
User                Subject              Grade
John                Physics               D
                          Social                   C
Mark                Physics               A
                          Social                   B
Sam                 Social                  D
 
Thank you!

 

Labels (3)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Your data presentation suggests that they were obtained with stats values() which means that you'd have two separate multivalued fields. There is no relation between values in those fields. so you can't (easily) remove corresponding values from both fields. You should filter your values before summarizing them.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @CuriousSplunky ,

supponing that you created the table using a stats command, you have only to add a search command after the stats:

<your_search>
| stats values(grade) AS Grade BY User Subject
| search Subject IN (Physics, Social)

Ciao.

Giuseppe

0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @CuriousSplunky .. your current search query and the sample data would be better to have.. thanks. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What do your raw events look like?

0 Karma
Get Updates on the Splunk Community!

How to Get Started with Splunk Data Management Pipeline Builders (Edge Processor & ...

If you want to gain full control over your growing data volumes, check out Splunk’s Data Management pipeline ...

Out of the Box to Up And Running - Streamlined Observability for Your Cloud ...

  Tech Talk Streamlined Observability for Your Cloud Environment Register    Out of the Box to Up And Running ...

Splunk Smartness with Brandon Sternfield | Episode 3

Hello and welcome to another episode of "Splunk Smartness," the interview series where we explore the power of ...