Splunk Search

Change Row Values to Column Headings

IRHM73
Motivator

Hi, I wonder whether someone may be able to help me please.

I'm using the query below which extracts a column of fields associated with the index and auditSource:

(index=main) OR (index=dg_<indexname>) auditSource=<fieldvalue>
| fieldsummary 
| where like(field, "detail.%")
| fields field
| rename field as data

I'm trying to change this so the row values become the 'column' headers.

I've tried using the 'transpose' command (below and also the 'chart over', but I can get neither to work

(index=main) OR (index=dg_tax-credits-submissions) auditSource=tax-credits-submissions
| fieldsummary 
| where like(field, "detail.%")
| fields field
| rename field as data
| transpose 0 header_field=data

I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.

Many thanks and kind regards

Chris

0 Karma
1 Solution

rjthibod
Champion

The transpose command needs another column in the data in order to handle what you are trying to do. You were correct in how to use the command, but the data preparation needs a bit more. This will add a count column that ends up being the only row after transpose. After that, you can remove that or change its contents depending on your use case.

 (index=main) OR (index=dg_tax-credits-submissions) auditSource=tax-credits-submissions
| fieldsummary 
| where like(field, "detail.%")
| fields field
| rename field as data
| chart count by data
| transpose 0 header_field=data

View solution in original post

rjthibod
Champion

The transpose command needs another column in the data in order to handle what you are trying to do. You were correct in how to use the command, but the data preparation needs a bit more. This will add a count column that ends up being the only row after transpose. After that, you can remove that or change its contents depending on your use case.

 (index=main) OR (index=dg_tax-credits-submissions) auditSource=tax-credits-submissions
| fieldsummary 
| where like(field, "detail.%")
| fields field
| rename field as data
| chart count by data
| transpose 0 header_field=data

IRHM73
Motivator

Hi @rjthibod, many thanks for coming back to me with this.

I made a slight adjustment and added a| fields - column at the end of the query.

Regards

Chris

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...