Splunk Enterprise

Custom Search

vishwa
Path Finder

Query:

|tstats count where index=xxx host=host1   sourcetype=newsourcetype by PREFIX(type:) _time
|rename type: as Types
|timechart span=1d values(count) by Types
|eval Total=Model1 +Model2+ Model3+ Model4
|fillnull value=0


OUTPUT:

_timeModel1Model2Model3Model4Total
2021-04-1220140
2021-04-1304000
2021-04-148210424
2021-04-1530280
2021-04-1614229

 

EXPECTED OUTPUT:

_timeModel1Model2Model3Model4Total
2021-04-1220147
2021-04-1304004
2021-04-148210424
2021-04-15302813
2021-04-1614229
Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

@vishwa I suspect your fields are not actually coming out as Model1 etc, i.e. the may have some strange characters in there. You can either try to figure out what the Types field values are before you do the timechart by doing something like

|tstats count where index=xxx host=host1   sourcetype=newsourcetype by PREFIX(type:) _time
|rename type: as Types
| head 10
| eval types=":".Types.":", len=len(Types)
| table Types types len

to see if there are any odd characters or the len does not come out as 8.

The simples thing to do though is to not care about the names and just add 'addtotals', i.e.

|tstats count where index=xxx host=host1   sourcetype=newsourcetype by PREFIX(type:) _time
| rename type: as Types
| timechart span=1d values(count) by Types
| addtotals

which will add up all the numeric fields and create a new field called Total

vishwa
Path Finder

Hi @bowesmana , Thank you!!!! this query worked

|tstats count where index=xxx host=host1   sourcetype=newsourcetype by PREFIX(type:) _time
| rename type: as Types
| timechart span=1d values(count) by Types
| addtotals

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

@vishwa re:mvstats - did you know that Splunk natively supports min/max/avg/sum on mvfields.

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...