Splunk Enterprise

How to show statistics of daily volume and latest events for all the sourcetypes in single table?

PavanSeerapu
Explorer

I want to show statistics of daily volume and latest events for all the sourcetypes in single table, can you please help.

Labels (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try to change the case of sourcetype to either lowercase or uppercase in both searches, like this:

index=_internal source=*metrics.log
| eval GB=kb/(1024*1024)
| search group="per_sourcetype_thruput"
| stats  sum(GB) by series | eval sourcetype=lower(series) 
| table sourcetype "sum(GB)"
| append [| tstats latest(_time) as latest where index=*  earliest=-24h by sourcetype  |eval LastReceivedEventTime  = strftime(latest,"%c")
|table sourcetype LastReceivedEventTime | eval sourcetype=lower(sourcetype)]
| stats values(*) as * by sourcetype

 

Regarding performance, what timerange are you using for your search?

View solution in original post

PavanSeerapu
Explorer
  • I got the individual query to get the latest time stamp and individual query to get the daily volume in GB , but i couldn't get the both in single query 
0 Karma

somesoni2
Revered Legend

Can you post the two queries that you're using?

They both come from different data sources (daily license usage comes from internal logs and event data comes from your data indexes), so you'd need to use append to combine both data sources.

0 Karma

PavanSeerapu
Explorer

index=_internal source=*metrics.log

| eval GB=kb/(1024*1024)

| search group="per_sourcetype_thruput"

| stats  sum(GB) by series

 

 

| tstats latest(_time) as latest where index=*  earliest=-24h by sourcetype

 |eval LastReceivedEventTime  = strftime(latest,"%c")

|table sourcetype LastReceivedEventTime

0 Karma

somesoni2
Revered Legend

Tstats queries are faster than regular query to I'll use them in append subsearch. Try something like this

index=_internal source=*metrics.log
| eval GB=kb/(1024*1024)
| search group="per_sourcetype_thruput"
| stats  sum(GB) by series | rename series as sourcetype
| append [| tstats latest(_time) as latest where index=*  earliest=-24h by sourcetype  |eval LastReceivedEventTime  = strftime(latest,"%c")
|table sourcetype LastReceivedEventTime ]
| stats values(*) as * by sourcetype

PavanSeerapu
Explorer

When using this query getting sourcetypes as duplicates one starting with capital and one starting with small as shown below, beacuse of this values are not appending correctly.

WinEventLog:Security

Thu Jun  9 02:35:06 2022

 

wineventlog:security

 

33.97319556

 

0 Karma

somesoni2
Revered Legend

Try to change the case of sourcetype to either lowercase or uppercase in both searches, like this:

index=_internal source=*metrics.log
| eval GB=kb/(1024*1024)
| search group="per_sourcetype_thruput"
| stats  sum(GB) by series | eval sourcetype=lower(series) 
| table sourcetype "sum(GB)"
| append [| tstats latest(_time) as latest where index=*  earliest=-24h by sourcetype  |eval LastReceivedEventTime  = strftime(latest,"%c")
|table sourcetype LastReceivedEventTime | eval sourcetype=lower(sourcetype)]
| stats values(*) as * by sourcetype

 

Regarding performance, what timerange are you using for your search?

jamie00171
Communicator

Hi All, 

if you add TERM() around group=per_sourcetype_thruput you'll read less event off disk which might make a noticeable difference depending on the time range of the search e.g.

index=_internal source=*metrics.log TERM(group=per_sourcetype_thruput)
| eval GB=kb/(1024*1024)
0 Karma

PavanSeerapu
Explorer

If im using TERM im not getting any events 😞

0 Karma

PavanSeerapu
Explorer

It worked but taking lot of time for the search to get complete 😞

0 Karma

aasabatini
Motivator

Hi @PavanSeerapu 

I think the bestway is metadata

try this search to check the count of events splitted by sourcetype

| metadata type=sourcetypes index=*

Regards

“The answer is out there, Neo, and it’s looking for you, and it will find you if you want it to.”
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...