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 🙂 *
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 🙂 *
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 🙂 *
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 🙂 *
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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...