Splunk Search

How to sort a chart horizontally by a field from greatest to least?

metersk
Path Finder

The search below gives me the following data:

(ns=stats msg=email_unsub_clicks) OR (ns=email msg=fbl OR msg=send OR msg=click) | eval t=tid%100  | eval v=version%100 |  eval a=coalesce(t,v) | chart count by msg, a

msg                | 1  | 12 | 19 | 2  | 3  | 49 | 56 | 74 | 8   | 9   |OTHER |
+------------------+----+----+----+----+----+----+----+----+-----+-----+------+
click              | 54 | 34 | 87 |208 | 77 | 67 |504 |372 | 962 | 197 |  208 |
email_unsub_clicks | 5  | 4  | 6  | 1  | 0  | 5  | 7  | 1  | 28  | 77  |  15  |
fbl                | 0  | 0  | 0  | 0  | 0  | 0  | 1  | 0  | 1   | 0   |  3   |
send               |1807|1007|1939|1264|712 |1244|9632|1748|14578|33175| 992  |

Is it possible to sort the bottom row, sends, from greatest to least?


Update:

So, the below is giving me the data vertically, but when I add the second transpose it does some weird stuff and removes most of the data

(ns=stats msg=email_unsub_clicks) OR (ns=email msg=fbl OR msg=send OR msg=click) | eval t=tid%100  | eval v=version%100 |  eval a=coalesce(t,v) | chart count by msg, a limit=7 | transpose | sort -"row 4"

+------------+-------+--------------------+-------+-------+
|     column | row 1 |       row 2        | row 3 | row 4 |
+------------+-------+--------------------+-------+-------+
|     msg    | click | email_unsub_clicks | fbl   | send  |
|     8      | 1029  | 26                 | 1     | 12104 |
|     1      | 96    | 11                 | 1     | 1789  |
|     74     | 417   | 2                  | 0     | 1746  |
|     2      | 232   | 1                  | 0     | 1192  |
|     12     | 27    | 1                  | 0     | 928   |
|     19     | 79    | 2                  | 0     | 756   |
|     3      | 86    | 0                  | 0     | 623   |
+------------+-------+--------------------+-------+-------+


(ns=stats msg=email_unsub_clicks) OR (ns=email msg=fbl OR msg=send OR msg=click) | eval t=tid%100  | eval v=version%100 |  eval a=coalesce(t,v) | chart count by msg, a limit=7 | transpose | sort -"row 4" | transpose
+------------+--------------------+-------+-------+-------+-------+
|     column |       row 1        | row 2 | row 3 | row 4 | row 5 |
+------------+--------------------+-------+-------+-------+-------+
|     column | msg                |     8 |     1 |    74 |     2 |
|     row 1  | click              |  1060 |    96 |   414 |   229 |
|     row 2  | email_unsub_clicks |    32 |    10 |     2 |     0 |
|     row 3  | fbl                |     1 |     1 |     0 |     0 |
|     row 4  | send               | 12198 |  1773 |  1724 |  1226 |
+------------+--------------------+-------+-------+-------+-------+
Tags (3)
0 Karma

ckp123
Path Finder

can you try


| transpose 0 header_field=msg | sort -send  | transpose 0 header_field=msg

0 Karma

Richfez
SplunkTrust
SplunkTrust

I don't have easy data around to try it with well enough to say it WILL work, but could you play with ... | transpose | sort -send | transpose | ... ?

You'll probably have to rewrite the above a bit. 🙂

metersk
Path Finder

Hello! Thanks for the response. I updated my question. For some reason the second transpose is giving me a weird return. Any thoughts?

0 Karma
Get Updates on the Splunk Community!

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...

Observability protocols to know about

Observability protocols define the specifications or formats for collecting, encoding, transporting, and ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...