Splunk Search

Percentage Timechart

paulf
Explorer

Hi All,

I am trying to plot the percentage of "total requests" vs "total errors" and am unfortunately in need of help.

I struggled for a good day now, using lots of different methods to do this, im fairly new to Splunk so any help would be appreciated.

Ok, simply.... my data can be searched using the below.

sourcetype="tcsb_webintel" ServiceName="MCS (Middleware Communication Service)" (AvailableFaresRequestMessage OR GetScheduledAirAvailabilityRequestMessage)

This will bring back all requests, all of which have HasError=0 or HasError=1 in the data to signify an error exists with that particular request.

i,e if i just wanted all errors i could search for ...
sourcetype="tcsb_webintel" ServiceName="MCS (Middleware Communication Service)" (AvailableFaresRequestMessage OR GetScheduledAirAvailabilityRequestMessage) HasError=1

What i am after is to show the total requests on a timechart, along with the percentage those requests that had errors.

I wont post what i have tried already as i have tried a few different ways, appending searches, using eval etc, none of which i could bend to my will.

i would greatly appreciate any assistance or guidance in the correct way to approach this....

Thanks
Paul

Tags (1)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

This should do something like what you want;

... | timechart span=1m c(eval(HasError=1)) AS err c AS tot | eval err_ratio_perc = round(err/tot*100,0)

the round() and multiplication by 100 are not necessary, but produces '16' instead of '0.16000'

Hope this helps,

Kristian

View solution in original post

kristian_kolb
Ultra Champion

This should do something like what you want;

... | timechart span=1m c(eval(HasError=1)) AS err c AS tot | eval err_ratio_perc = round(err/tot*100,0)

the round() and multiplication by 100 are not necessary, but produces '16' instead of '0.16000'

Hope this helps,

Kristian

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 ...