Splunk Search

How to calculate the SLA percentage from start event query and end event query?

Sekhar
Explorer

I have two events one is  calculate the SLA percentage from below querys

 

Start event query 

Index=x source type= xx "saved msg" extacted fields s like manid,actionid,batch I'd

End event query

Index=y source type=y " recived msg" extacted fields like manid ,actionid

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

(index=x source type=xx "saved msg") OR (index=y source type=y " recived msg")
| stats values(_time) as time values(actionid) as actionid values(batchid) as batchid by manid
| eval duration = max(time) - min(time)
| stats count count(eval(duration > 30)) as exceeded
| eval slapercentagefailure = 100*exceeded/count

View solution in original post

0 Karma

woodcock
Esteemed Legend

(index="X" AND sourcetype="xx" AND "saved msg")
OR (Index="y" AND sourcetype="yy" AND "recived msg")
| streamstats count(eval(match(_raw, "recived msg"))) AS sessionID BY manid actionid
| stats count(eval(match(_raw, "saved msg"))) AS savedCount range(_time) AS duration min(_time) AS _time BY sessionID
| stats count AS total count(eval((savedCount > 0 AND duration > 30) OR (savedCount==0 AND (now() - _time) > 30))) AS SLA_blown
| eval SLA_percentage = 100 * (total - SLA_blown) / total

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What exactly do you mean by "SLA percentage"?

SLA usually means Service Level Agreement, so SLA percentage, is that the percentage of people that have signed up to the agreement, out of everyone in your organisation, or at least the key stakeholders in whatever service is being provided?

0 Karma

Sekhar
Explorer

Calculate different between start and end events grouped by manid and count number of mandate execceding different above 30 sec 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

(index=x source type=xx "saved msg") OR (index=y source type=y " recived msg")
| stats values(_time) as time values(actionid) as actionid values(batchid) as batchid by manid
| eval duration = max(time) - min(time)
| stats count count(eval(duration > 30)) as exceeded
| eval slapercentagefailure = 100*exceeded/count
0 Karma

Sekhar
Explorer

Getting result like below 

Count       exceeded.   slapercentagefailure

66                1              1.5152

Same way can add the | stats count by date_hour

For SLA trendy by time of the day??

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Which date_hour, when the start event happens or the end event?

0 Karma

Sekhar
Explorer

Calculate different between start and end events grouped by manid and count number of mandate execceding different above 30 sec.  SLA trendy by time of the day.

Can I add any field for day_hour above query?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Sure - which time do you want to use, the min(time) or the max(time)?

0 Karma

Sekhar
Explorer

Min(time)

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
(index=x source type=xx "saved msg") OR (index=y source type=y " recived msg")
| stats values(_time) as time values(actionid) as actionid values(batchid) as batchid min(_time) as _time by manid
| eval duration = max(time) - min(time)
| bin _time span=1h
| stats count count(eval(duration > 30)) as exceeded by _time
| eval slapercentagefailure = 100*exceeded/count
0 Karma

Sekhar
Explorer

Min(time)

0 Karma

Sekhar
Explorer

Getting result like below 

Count       exceeded.   slapercentagefailure

66               1.                     1.5152

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...