Splunk Search

How do you put a single row of key value pairs into one line from multiple rows?

lylereger
New Member

I have looked at various answers, but don't seem to be grasping what seems like it should be easy enough to do. Some help would be appreciated. Here is my set up.

I have data that comes back in a few simple fields(from JSON originally):

id      name      category     catval
123     bob       math         89
123     bob       English      76
123     bob       science      94
124     joe       math         79
124     joe       English      83
124     joe       science      91

And the output I am looking for is:

 id      name      math     English   science
123      bob       89       76        94
124      joe       79       83        91

Can anyone point me in the right direction here? If it helps, I do not have to dynamically determine the category field. I will know those values. I do need to grab them and get them sorted into single rows though.

Tags (1)
0 Karma

Vijeta
Influencer

Hi,

You can try something like below-

  <yourquery>|  eval id=id.",".name
    |chart sum(catval) as val over id by  catgory|  rex field=id "\w+,(?<name>\w+)"
| rex field=id "(?<id>\w+),"

|  table id name *
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...