Splunk Dev

How to create a chart or table that shows results for multiply sourcetypes.

mrtolu6
Path Finder

I want to create a chart separated by hours (24hours) and grouped by the sourcetype that shows the number of data that took more than 2 mins to be indexed (indextime-time) and converted into percent. The percent would be the total event that took over 2mins to be indexed divided by the total number of events for that hour.(for that 1 hour span). The result shold be grouped by the sourcetype

This is the basic search I'm using to calculate the events over 2mins
earliest=-24h@h latest=@h index=nameoftheindex
| eval GT2=if(_indextime-_time>=120,1,0)
| bin _time span=1h
| stats avg(GT2) as PctGT2 by _time

Tags (1)
0 Karma
1 Solution

DalJeanis
SplunkTrust
SplunkTrust
earliest=-24h@h latest=@h index=nameoftheindex 
| eval GT2=if(_indextime-_time>=120,1,0)
| bin _time span=1h
| stats avg(GT2) as PctGT2 by _time sourcetype
| eval PctGT2=round(100*PctGT2,2)
| timechart avg(pctGT2) as pctGT2 by sourcetype

Technically, if you are going to use timechart, you wouldn't have to bin the _time and stats for the avg, since timechart will handle that in a single step.

earliest=-24h@h latest=@h index=nameoftheindex 
| eval GT2=if(_indextime-_time>=120,100,0)
| timechart span=1h avg(GT2) as pctGT2 by sourcetype

View solution in original post

0 Karma

DalJeanis
SplunkTrust
SplunkTrust
earliest=-24h@h latest=@h index=nameoftheindex 
| eval GT2=if(_indextime-_time>=120,1,0)
| bin _time span=1h
| stats avg(GT2) as PctGT2 by _time sourcetype
| eval PctGT2=round(100*PctGT2,2)
| timechart avg(pctGT2) as pctGT2 by sourcetype

Technically, if you are going to use timechart, you wouldn't have to bin the _time and stats for the avg, since timechart will handle that in a single step.

earliest=-24h@h latest=@h index=nameoftheindex 
| eval GT2=if(_indextime-_time>=120,100,0)
| timechart span=1h avg(GT2) as pctGT2 by sourcetype
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...