Splunk Search

untranspose multi-field sparkline

coo
Explorer
| chart sparkline count by a,b

I would like to have sparkline table like...

a      | b   | count | sparkline
thing1 | foo | 123 | _^_
thing2 | bar | 456 | _^_

But sparkline does an implicit transpose like...

a      | count: foo | count: bar | sparkline: foo | sparkline: bar
thing1 | 123 | 0 | _^_ | 
thing2 | 0 | 456 | | _^_

Is it possible to produce the desired table?

Labels (1)
0 Karma
1 Solution

asimit
Path Finder

Hey @coo 

I had the exact same issue previously with chart sparkline count by field1,field2 - it always transposes and gives you columns instead of nice rows.


Here's the clean fix that works perfectly:

index=_internal sourcetype=splunkd*
| rename host as a, sourcetype as b
| stats count as count by _time a b
| fillnull value=0 count
| stats sparkline(count) as sparkline
        sum(count) as count
        by a b
| table a b count sparkline

 

What it does:

  1. stats count by _time a b → gets time-series data per host+sourcetype

  2. fillnull value=0 → handles gaps for smooth sparklines

  3. stats sparkline(count) ... by a b → one sparkline per host+sourcetype row

  4. Perfect table: a | b | count | sparkline

Seen the attached screenshot for better understanding, No more transpose headaches!

Please give 👍 for support 😁 happly splunking .... 😎

 

View solution in original post

asimit
Path Finder

Hey @coo 

I had the exact same issue previously with chart sparkline count by field1,field2 - it always transposes and gives you columns instead of nice rows.


Here's the clean fix that works perfectly:

index=_internal sourcetype=splunkd*
| rename host as a, sourcetype as b
| stats count as count by _time a b
| fillnull value=0 count
| stats sparkline(count) as sparkline
        sum(count) as count
        by a b
| table a b count sparkline

 

What it does:

  1. stats count by _time a b → gets time-series data per host+sourcetype

  2. fillnull value=0 → handles gaps for smooth sparklines

  3. stats sparkline(count) ... by a b → one sparkline per host+sourcetype row

  4. Perfect table: a | b | count | sparkline

Seen the attached screenshot for better understanding, No more transpose headaches!

Please give 👍 for support 😁 happly splunking .... 😎

 

coo
Explorer

Thanks for responding. Here is my ultimate solution.

| stats count by _time,a,b
| stats sum(count) as count,sparkline(count) as sparkline by a,b
| sort -count

richgalloway
SplunkTrust
SplunkTrust

Use the table command to put the fields in the desired order

| chart sparkline count by a,b
| table a b count sparkline

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

coo
Explorer

Thanks for responding. This was the result.

a      | b   | count | sparkline
thing1 | | |
thing2 | | |
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...