Splunk Search
Highlighted

Addtotals in table issue

Builder

Hello, I'd like to add totals to remove the two-lines result per row, how to do? Thanks.

Tags (2)
0 Karma
Highlighted

Re: Addtotals in table issue

SplunkTrust
SplunkTrust

See if this works:

| multisearch 
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_TOTAL | rename counter as total_count]
[search index=d2i sourcetype=D2I_Fichesconsolidees typ_stat=*_PERMIS | rename counter as perm_count]
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

Note, you need to use the different "e" in Ficheconsolidees as I dont have this "e" on my keyboard.

Even better though:

index=d2i sourcetype=D2I_Fichesconsolidees (typ_stat=*_TOTAL OR typ_stat=*PERMIS) 
| eval total_count=if(typ_stat=*_TOTAL,counter,null()) 
| eval perm_count=if(typ_stat=*_PERMIS,counter,null()) 
| stats sum(total_count) as total_count sum(perm_count) as perm_count by type_fiche

View solution in original post

Highlighted

Re: Addtotals in table issue

Builder

| multisearch
[search index=d2i sourcetype=D2IFichesconsolidées typstat=TOTAL | rename counter as totalcount]
[search index=d2i sourcetype=D2IFichesconsolidées typstat=
PERMIS | rename counter as permcount]
| stats sum(totalcount) as totalcount sum(permcount) as permcount by typ_fiche

Dear Michael, first search worked (just a mistake at 'typ_fiche'), thanks a lot!

Second search was giving an error at eval :

Error in 'eval' command: The expression is malformed. An unexpected character is reached at '*_TOTAL,counter,null())'.

0 Karma
Highlighted

Re: Addtotals in table issue

SplunkTrust
SplunkTrust

OK great, but you want to run just one search for this as it is more efficient, uses less cpu, memory, etc. Try this too please:

 index=d2i sourcetype=D2I_Fichesconsolidees (typ_stat=*_TOTAL OR typ_stat=*PERMIS) 
 | eval total_count=if(match(typ_stat,"*_TOTAL"),counter,null()) 
 | eval perm_count=if(match(typ_stat,"*_PERMIS"),counter,null()) 
 | stats sum(total_count) as total_count sum(perm_count) as perm_count by typ_fiche
0 Karma
Highlighted

Re: Addtotals in table issue

Builder

"Error in 'eval' command: Regex: nothing to repeat"

0 Karma
Highlighted

Re: Addtotals in table issue

Contributor

Take a look at the like and match functions in the Search Reference documentation, you should probably be able to use either to accomplish the solution proposed by jkat54.

I could attempt a solution, but you won't be learning anything that way. If you are still having problems having read the documentation, post the searches you've tried and how they're failing to produce the desired results. If you are successful it would be nice to see the query you decided to use.

Dave

0 Karma
Highlighted

Re: Addtotals in table issue

Builder

Thanks Dave, anyway I've already got a solution provided by Michael.

0 Karma
Highlighted

Re: Addtotals in table issue

Contributor

My comment was referring to the "Error in 'eval' command: Regex: nothing to repeat" message. If you have a solution that matches your needs then Happy Splunking.

Dave

0 Karma