Splunk Search

Is there a way to get the addcototals to show in the first column instead of appending to the last?

Substance82
Path Finder

Here is my current query. I either get the Totals label in the last column or not at all. I need it to show in the first column at the beginning of the Totals row. Any help is greatly appreciated. Thanks. 

index=etims_na
sourcetype=etims_prod
platformId=5
bank_fiid=CHUA
| eval response_time=round(if(strftime(_time,"%Z") == "EDT",((j_timestamp-entry_timestamp)-14400000000)/1000000,((j_timestamp-entry_timestamp)-14400000000)/1000000-3600),3)
| stats count AS Transactions count(eval(response_time <= 1)) AS "Good" count(eval(response_time <= 2)) AS "Fair" count(eval(response_time > 2)) AS "Unacceptable" avg(response_time) AS "Average" BY bank_fiid
| eval "%Good"=(Good/Transactions)*100
| eval "%Fair"=(Fair/Transactions)*100
| eval "%Unacceptable"=(Unacceptable/Transactions)*100
| addinfo
| eval "Report Date"=strftime(info_min_time, "%m/%Y")
| table bank_fiid, "Transactions", "Good", "%Good" "Fair", "%Fair", "Unacceptable", "%Unacceptable", "Average", "Report Date"
| rename bank_fiid as "Vision ID"
| addcoltotals label=Total
| append [|makeresults
| eval "Vision ID"="Threshold"
| eval "Good" = "response <= 1s"
| eval "Fair" = "1s < response <= 3s"
| eval "Unacceptable" = "3s < response"]
| fields - _time
Labels (3)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the labelfield option.  It tells Splunk into which field (column) to put the total.

...
| table bank_fiid, "Transactions", "Good", "%Good" "Fair", "%Fair", "Unacceptable", "%Unacceptable", "Average", "Report Date"
| rename bank_fiid as "Vision ID"
| addcoltotals label=Total labelfield=bank_fiid
...

 

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

View solution in original post

Substance82
Path Finder

Never mind. I posted too soon. I replaced "| addcoltotals label=Total " with "| addcoltotals labelfield="Vision ID" label="Total"" and it worked. Thanks.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use the labelfield option.  It tells Splunk into which field (column) to put the total.

...
| table bank_fiid, "Transactions", "Good", "%Good" "Fair", "%Fair", "Unacceptable", "%Unacceptable", "Average", "Report Date"
| rename bank_fiid as "Vision ID"
| addcoltotals label=Total labelfield=bank_fiid
...

 

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

Substance82
Path Finder

Thanks! This was exactly the fix I found. 

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...