4

I have a use case to alert in case of SLA miss. My application emits metric on startTime (M1) & endTime (M2). If my job completes, I will be able to know SLA misses by doing metric math like (M2-M1) and having alerting on this.

But if my job is stuck, I still want to get alerted by computing (currentTime-M1) (may be on scheduled basis). Is this possible with AWS CloudWatch? Non-AWS based approaches & solutions are also welcome!!

blrguy
  • 131
  • 6

1 Answers1

0

Maybe you can create a CloudWatch insight query, something like this:

fields ispresent(execution_arn) as isRes
| filter isRes 
| filter type in ["ExecutionStarted", "ExecutionSucceeded", "ExecutionFailed", "ExecutionAborted", "ExecutionTimedOut"]
| stats latest(type) as status, 
  earliest (event_timestamp) as starttime, 
  latest (event_timestamp) as endtime, 
  endtime - starttime as duration  by execution_arn
| sort duration desc

you will have to enable CW logs for state machine: https://docs.aws.amazon.com/step-functions/latest/dg/cw-logs.html

Pooya Paridel
  • 1,261
  • 5
  • 10