Knowledge Management

Need to add a separator in Stats table between each Sort

arunsubram
Explorer

----| stats sparkline as magnitude_trend,count by rest_api_name,http_status_code,a | lookup AppIdLookUp a OUTPUT PartnerName | sort PartnerName

Above is my query to do refer a lookup file and populate the PartnerName. Currently I have about 100+ PartnerNames and each Partner has 5 to 10 rest api names. My stats table look like big grid.

For easy reading, I wanted to add a colored space row or separator after each PartnerName sorted like below

restname1 statuscode-400 count PartnerA
restname2 statuscode-400 count PartnerA
restname3 statuscode-400 count PartnerA

restname1 statuscode-400 count PartnerB
restname2 statuscode-500 count PartnerB
restname3 statuscode-401 count PartnerB

restname1 statuscode-200 count PartnerC
restname2 statuscode-400 count PartnerC
restname3 statuscode-500 count PartnerC

Appreciate any suggestions

Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

To generate the row itself, you could do something like this:

... | stats ... | lookup ... | appendpipe [stats count by PartnerName | fields - count | eval rest_api_name="ZZZ make sure this causes the row to sort towards the end"] | sort PartnerName rest_api_name | eval rest_api_name=case(NOT match(rest_api_name, "^ZZZ"), rest_api_name)

That should insert a row per partner, set the rest name to some placeholder to be sorted towards the end, do the sort, hide the placeholder.

Colouring the separator row can be done with a bit of JS and CSS in dashboards.

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

To generate the row itself, you could do something like this:

... | stats ... | lookup ... | appendpipe [stats count by PartnerName | fields - count | eval rest_api_name="ZZZ make sure this causes the row to sort towards the end"] | sort PartnerName rest_api_name | eval rest_api_name=case(NOT match(rest_api_name, "^ZZZ"), rest_api_name)

That should insert a row per partner, set the rest name to some placeholder to be sorted towards the end, do the sort, hide the placeholder.

Colouring the separator row can be done with a bit of JS and CSS in dashboards.

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!

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 ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...