Splunk Search

Extracting the values from addtotals/addcoltotals from timechart.

ronaldtanhj
Path Finder

Hi All,

I would like to extract the values from addtotals.

My current result from my search is as follows;

_timefieldafieldbfieldcfielddTotal by Day
day_112126
day_222228
day_....11114
day_n312411
Total by field7669 

 

The last lines of my search is as follows:

 

|....
|timechart span=1d sum(A) as B by C limit=0
|addtotals col=t labelfield=_time label="Total by Field" fieldname="Total by Day"

 

 

After the 'addtotals' portion, I would like to extract out the values of "Total by Field" (shown in bold and underlined) for further calculations. Or if there is an alternative method to use instead of 'addtotals'

I've tried stats sum and eval to do so but couldn't do it.

 

Anyone here able to advise on this?

 

Thanks and advance!

Labels (4)
0 Karma

kennetkline
Path Finder

If you want to see sum totals then just truncate _time (by day) drop the time:

Then do sum using stats by day;  something like this;  I put total_by_day as total record count in case you want to care it down to see; but was not a field you wanted, figured would show that.

search ...
| eval day=strftime(_time, "%Y-%m-%d")
| stats sum(fielda) as total_a, sum(fieldb) as total_b, sum(fieldc) as total_c, sum(feildd) as total_d, count as total_by_day by day
| table day total_a, total_b, total_c, total_d
| rename day as "Total by Field"

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...