Skip to content

Instantly share code, notes, and snippets.

@lioneltchami
Created June 3, 2025 16:30
Show Gist options
  • Save lioneltchami/4d3314a831582961edd38d4e0f600a27 to your computer and use it in GitHub Desktop.
Save lioneltchami/4d3314a831582961edd38d4e0f600a27 to your computer and use it in GitHub Desktop.
🧠 Metric #4: Task Restart Rate (Failure Monitoring) Use TaskStoppedCount metric to detect frequent task restarts:
resource "awscc_applicationsignals_service_level_objective" "task_restart_slo" {
name = "ecs-task-restart-slo"
description = "Monitor ECS task restart frequency"
sli = {
comparison_operator = "LessThan"
metric_threshold = 1.0 # 1 or fewer per 5 min
sli_metric = {
metric_data_queries = [{
id = "restarts"
metric_stat = {
metric = {
namespace = "ECS/ContainerInsights"
metric_name = "TaskStoppedCount"
dimensions = [
{
name = "ClusterName"
value = "my-cluster-name"
},
{
name = "ServiceName"
value = "my-service-name"
}
]
}
period = 300
stat = "Sum"
}
}]
}
}
goal = {
attainment_goal = 99.0
interval = {
rolling_interval = {
duration = 7
duration_unit = "DAY"
}
}
}
burn_rate_configurations = [
{ look_back_window_minutes = 60 },
{ look_back_window_minutes = 1440 }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment