0

Ask: Generate a graph which should show day wise percentage of API success/Availability data in a Splunk dashboard.

Data(search based on specific string) is based on the total number of Success calls on API Named as 'ABC' and Total number of failure calls on API Named as 'ABC' for given period.

Appreciate any pointers for generating the Splunk query for displaying success percentage in day wise graph.

Query tried :

index=app_index "ABC Api call success"  
| stats count(unique_success_string) as sucessCall
| appendcols [search index=app_index "ABC Failure call" | stats(unique_failure_string) as fialuresCall] 
| eval percentage = (sucessCall/fialuresCall)*100 
| fields _time percentage 
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
fregp
  • 29
  • 2
  • 6

1 Answers1

1

To get per-day statistics, the results need to broken up by day. Use the bin or timechart command for that. Also, the appendcols command is unnecessary as the stats and timechart commands can calculate two numbers at the same time.

index=app_index ("ABC Api call success" OR "ABC Failure call")
| bin span=1d _time
| stats sum(eval(match(_raw,unique_success_string))) as sucessCall,
        sum(eval(match(_raw,unique_failure_string))) as fialuresCall by _time
| eval percentage = (sucessCall/fialuresCall)*100 
| fields _time percentage 
RichG
  • 9,063
  • 2
  • 18
  • 29