Initial monitoring of cloudwatch logs (#136)
This commit is contained in:
1 parent
8765c8c1e0
commit
ed4d3c01de
2 files changed
+43
No files matched your search
@@ -40,6 +40,37 @@ locals {
|
||||
alb_map = { for k, v in var.albs : k => v }
|
||||
}
|
||||
|
||||
// Log-based monitoring
|
||||
resource "aws_cloudwatch_log_metric_filter" "log_monitoring" {
|
||||
for_each = var.log_monitoring
|
||||
|
||||
name = "${var.customer_prefix}-log-monitor-${each.key}"
|
||||
log_group_name = each.value.log_group_name
|
||||
pattern = each.value.pattern
|
||||
|
||||
metric_transformation {
|
||||
name = "${var.customer_prefix}-${each.key}"
|
||||
namespace = "${var.customer_prefix}-logs"
|
||||
value = "1"
|
||||
unit = "Count"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_metric_alarm" "log_monitoring" {
|
||||
for_each = var.log_monitoring
|
||||
alarm_name = "${var.customer_prefix}-log-monitor-${each.key}"
|
||||
comparison_operator = "GreaterThanOrEqualToThreshold"
|
||||
evaluation_periods = each.value.evaluation_periods
|
||||
metric_name = "${var.customer_prefix}-${each.key}"
|
||||
namespace = "${var.customer_prefix}-logs"
|
||||
period = each.value.period
|
||||
statistic = "Sum"
|
||||
threshold = each.value.threshold
|
||||
treat_missing_data = "notBreaching"
|
||||
alarm_actions = lookup(var.sns_topic_arns_map, "log_monitoring", var.default_sns_topic_arns)
|
||||
ok_actions = lookup(var.sns_topic_arns_map, "log_monitoring", var.default_sns_topic_arns)
|
||||
}
|
||||
|
||||
|
||||
// ECS Alarms
|
||||
resource "aws_cloudwatch_metric_alarm" "alb_healthyhosts" {
|
||||
|
||||
@@ -68,6 +68,18 @@ variable "acm_certificate_arn" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "log_monitoring" {
|
||||
description = "Map of CloudWatch log monitors to create. Key is used as a suffix for resources and metric naming."
|
||||
type = map(object({
|
||||
log_group_name = string
|
||||
pattern = string
|
||||
evaluation_periods = number
|
||||
period = number
|
||||
threshold = number
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cron_monitoring" {
|
||||
type = object({
|
||||
mysql_host = string
|
||||
|
||||
Reference in new issue
Block a user