Skip to content

Commit

Permalink
Improving metrics scraper ECS task definition example - adding health…
Browse files Browse the repository at this point in the history
… checks. Adding comments to application service to reason tag used for flitering.
  • Loading branch information
alex-tsbk committed Aug 28, 2024
1 parent 11084d2 commit e2247be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
39 changes: 22 additions & 17 deletions example/modules/application/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ resource "aws_ecs_service" "service" {

}

# Uncomment below to enable load balancer support for your application.
# You'll have to create variables & pass the list of target group ARNs to the module.
# dynamic "load_balancer" {
# for_each = var.target_group_arns
#
# content {
# target_group_arn = load_balancer.value
# container_name = local.ecs_service_name
# container_port = 8080
# }
# }
# Uncomment below to enable load balancer support for your application.
# You'll have to create variables & pass the list of target group ARNs to the module.
# dynamic "load_balancer" {
# for_each = var.target_group_arns
#
# content {
# target_group_arn = load_balancer.value
# container_name = local.ecs_service_name
# container_port = 8080
# }
# }

lifecycle {
ignore_changes = [
Expand Down Expand Up @@ -171,11 +171,16 @@ resource "aws_ecs_task_definition" "task_definition" {
# This duplicates the configuration in the CloudMap service resource ("aws_service_discovery_service.service_discovery")
# just to show how to set the same configuration at the ECS Task level. These configuration are resolved in a specific order.
# See appsettings.json for more details.
"METRICS_PORT" = "8080"
"METRICS_PATH" = "/metrics"
"METRICS_NAME" = "/application"
"METRICS_PORT_ECS" = "9779"
"METRICS_PATH_ECS" = "/metrics"
"METRICS_NAME_ECS" = "ecs-exporter"
"METRICS_PORT" = "8080"
"METRICS_PATH" = "/metrics"
"METRICS_NAME" = "/application"
"METRICS_PORT_ECS" = "9779"
"METRICS_PATH_ECS" = "/metrics"
"METRICS_NAME_ECS" = "ecs-exporter"
# This needs to alight with the "DiscoveryOptions__EcsServiceSelectorTags"
# in the "aws-ecs-cloudmap-prometheus-discovery" application.
# This allows to discover and scrape only those applications,
# which you're interested in.
"PROMETHEUS_TARGET" = "true"
})
}
8 changes: 8 additions & 0 deletions example/modules/monitoring/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ resource "aws_ecs_task_definition" "task_definition" {
value = var.ecs_cluster_name
},
{

name = "DiscoveryOptions__EcsServiceSelectorTags"
value = "PROMETHEUS_TARGET=true"
},
Expand All @@ -73,6 +74,13 @@ resource "aws_ecs_task_definition" "task_definition" {
value = local.region
}
]
healthCheck = {
command = ["CMD-SHELL", "curl -f http://localhost:9001/health || exit 1"]
interval = 30
timeout = 5
retries = 3
start_period = 60
}
logConfiguration = {
logDriver = "awslogs"
options = {
Expand Down

0 comments on commit e2247be

Please sign in to comment.