Splunk Search

Addtotals in table issue

splunkreal
Motivator

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

* If this helps, please upvote or accept solution if it solved *
Tags (2)
0 Karma
1 Solution

jkat54
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

splunkreal
Motivator

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

* If this helps, please upvote or accept solution if it solved *
0 Karma

davebrooking
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

splunkreal
Motivator

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

* If this helps, please upvote or accept solution if it solved *
0 Karma

davebrooking
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

jkat54
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

splunkreal
Motivator

| multisearch
[search index=d2i sourcetype=D2I_Fichesconsolidées typ_stat=_TOTAL | rename counter as total_count]
[search index=d2i sourcetype=D2I_Fichesconsolidées typ_stat=
_PERMIS | rename counter as perm_count]
| stats sum(total_count) as total_count sum(perm_count) as perm_count 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())'.

* If this helps, please upvote or accept solution if it solved *
0 Karma

jkat54
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
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...