generated from cds-snc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CloudWatch alarm for failed Glue jobs (#23)
Add an EventBridge rule and custom CloudWatch metric to capture failed Glue jobs. A new alarm has also been added to trigger when a failure occurs.
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
resource "aws_cloudwatch_event_rule" "glue_job_failure" { | ||
name = "glue-job-failures" | ||
description = "Capture Glue job failures and timeouts" | ||
|
||
event_pattern = jsonencode({ | ||
source = ["aws.glue"] | ||
detail-type = ["Glue Job State Change"] | ||
detail = { | ||
state = ["FAILED", "TIMEOUT", "ERROR"] | ||
} | ||
}) | ||
} | ||
|
||
resource "aws_cloudwatch_event_target" "glue_job_failure" { | ||
rule = aws_cloudwatch_event_rule.glue_job_failure.name | ||
target_id = "PublishMetric" | ||
arn = "arn:aws:events:${var.region}:${var.account_id}:api-destination/cloudwatch-metrics" | ||
|
||
input_transformer { | ||
input_paths = { | ||
jobName = "$.detail.jobName" | ||
state = "$.detail.state" | ||
} | ||
input_template = jsonencode({ | ||
MetricData = [{ | ||
MetricName = local.glue_job_failure_metric_name | ||
Value = 1 | ||
Unit = "Count" | ||
Dimensions = [{ | ||
Name = "JobName" | ||
Value = "<jobName>" | ||
}] | ||
}] | ||
Namespace = local.data_lake_namespace | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
locals { | ||
data_lake_namespace = "data-lake" | ||
glue_crawler_metric_filter_error_pattern = "ERROR" | ||
glue_crawler_error_metric_name = "glue-crawler-error" | ||
glue_job_failure_metric_name = "glue-job-failure" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Glue ETL job exports | ||
There is not currently a way to manage visual Glue ETL jobs with Terraform in a way that allows them to be edited in the console. | ||
|
||
The exports in this folder can be used to recreate our ETL jobs using the console or CLI if needed. |