Splunk Search

In a table output that uses the stats command, how do you convert a row to a header?

dtakacssplunk
Explorer

How do I convert the output of a table from stats command that looks like this:

TIME VALUE METRIC
time1 a 100
time1 b 200
time2 a 50
time2 b 90

To this?

TIME a b

time1 100 200
time2 50 90

0 Karma
1 Solution

chrisyounger
SplunkTrust
SplunkTrust

Hi @dtakacssplunk

xyseries will also do what you want

e.g.
index=_internal | eval len = len(_raw) |stats count by component log_level | head 10
becomes
index=_internal | eval len = len(_raw) |stats count by component log_level | head 10 | xyseries component log_level count

Good luck!

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @dtakacssplunk,

You can use chart also.

YOUR_SEARCH | chart values(METRIC) as METRIC over TIME by VALUE

Sample Search:

| makeresults | eval _raw="
TIME VALUE METRIC
time1 a 100
time1 b 200
time2 a 50
time2 b 90
" | multikv | chart values(METRIC) as METRIC over TIME by VALUE

Thanks

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Hi @dtakacssplunk

xyseries will also do what you want

e.g.
index=_internal | eval len = len(_raw) |stats count by component log_level | head 10
becomes
index=_internal | eval len = len(_raw) |stats count by component log_level | head 10 | xyseries component log_level count

Good luck!

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@dtakacssplunk,

Try,

"your current search "
|eval {VALUE}=METRIC|fields - VALUE,METRIC|stats values(*) as * by TIME
Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...