Skip to content

Commit

Permalink
add unit and default_value config (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennsimon authored Dec 4, 2024
1 parent c81bbf9 commit 0f285b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 5 additions & 6 deletions storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ resource "aws_cloudwatch_log_metric_filter" "slow_query_metric_filter" {
name = var.postgresql_slow_query_metric_filter_name
pattern = join("?", var.postgresql_slow_query_pattern)
metric_transformation {
name = var.postgresql_slow_query_metric_filter_name
namespace = var.postgresql_slow_query_metric_namespace
value = var.postgresql_slow_query_metric_value
name = var.postgresql_slow_query_metric_filter_name
namespace = var.postgresql_slow_query_metric_namespace
value = var.postgresql_slow_query_metric_value
unit = var.postgresql_slow_query_metric_unit
default_value = var.postgresql_slow_query_metric_default_value
}
}

Expand Down Expand Up @@ -341,7 +343,4 @@ resource "aws_cloudwatch_metric_alarm" "slow_query_metric_alarm" {
severity = var.postgresql_slow_query_severity
}

dimensions = {
DBInstanceIdentifier = (length(var.postgresql_source_snapshot_identifier) == 0 && var.postgresql_replicate_source_db == null) ? aws_db_instance.blank-database[0].identifier : var.postgresql_replicate_source_db != null ? aws_db_instance.replica-database[0].identifier : aws_db_instance.from-snapshot[0].identifier
}
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,18 @@ variable "postgresql_slow_query_metric_value" {
default = 1
}

variable "postgresql_slow_query_metric_unit" {
type = string
description = "Unit of measurement"
default = "Count"
}

variable "postgresql_slow_query_metric_default_value" {
type = number
description = "The default value is published to the metric when the pattern does not match. If you leave this blank, no value is published when there is no match"
default = 0
}

variable "postgresql_slow_query_pattern" {
type = list(string)
description = "The terms or pattern to match in your log events to create metrics"
Expand Down

0 comments on commit 0f285b0

Please sign in to comment.