Splunk Search

Httpstatuscode success/failure

lucky
Explorer

Hi All,

I have 3 API's 

1. in first API the status are code 200 & 403 as a success reaming all status codes are failure 

2. in 2nd & 3rd API's only 200 is the success  remaining all codes are failure 

I need to show graph as a line chart with "Y" axis as success percentage " 0 to 100"

in X-axis need to show time 

I have to use below time chart command like...

|timechart span=5m eval(if(count>10, round(mean(status),2), 100)) as percentage by countryCode useother=false limit=100

 

please help on this 

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You need to explain your data set in a data centric forum.  Assuming that you have a field named API with values "API1", "API2", etc., and a field named status with 200, 403, etc.  I think what you are looking for is

| eval success = if(API == "API1" AND status == "403" OR status == "200", 1, 0)
| bin span=5m _time
| stats count sum(success) as success by countryCode _time
| eval percentage = round(success * 100 / count, 2)
| timechart useother=false limit=100 span=5m values(percentage) as percentage by countryCode
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...