Skip to content

Commit 8a16b6b

Browse files
authored
Merge pull request #17 from rhythmictech/elasticache_update
aws/elasticache: allow customization of the organize by fields in mon…
2 parents 669dea1 + f2107cc commit 8a16b6b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

aws/elasticache/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ resource "datadog_monitor" "cpu_utilization" {
2727

2828
query = <<END
2929
avg(${var.cpu_utilization_evaluation_window}):
30-
avg:aws.elasticache.cpuutilization${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}
30+
avg:aws.elasticache.cpuutilization${local.query_filter} by {${var.query_organize_by_fields}}
3131
>= ${var.cpu_utilization_threshold_critical}
3232
END
3333

@@ -56,7 +56,7 @@ resource "datadog_monitor" "cpu_utilization_anomaly" {
5656

5757
query = <<END
5858
avg(${var.cpu_utilization_evaluation_window}):anomalies(
59-
avg:aws.elasticache.cpuutilization${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}, 'agile', ${var.cpu_utilization_anomaly_deviations},
59+
avg:aws.elasticache.cpuutilization${local.query_filter} by {${var.query_organize_by_fields}}, 'agile', ${var.cpu_utilization_anomaly_deviations},
6060
direction='above', count_default_zero='true', interval=${var.cpu_utilization_anomaly_rollup},
6161
seasonality='${var.cpu_utilization_anomaly_seasonality}'
6262
) >= ${var.cpu_utilization_anomaly_threshold_critical}
@@ -86,7 +86,7 @@ resource "datadog_monitor" "evictions" {
8686

8787
query = <<END
8888
sum(${var.evictions_evaluation_window}): (
89-
avg:aws.elasticache.evictions${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}
89+
avg:aws.elasticache.evictions${local.query_filter} by {${var.query_organize_by_fields}}
9090
) >= ${var.evictions_threshold_critical}
9191
END
9292

@@ -115,7 +115,7 @@ resource "datadog_monitor" "hit_rate" {
115115

116116
query = <<END
117117
max(${var.hit_rate_evaluation_window}):(
118-
avg:aws.elasticache.cache_hit_rate${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}
118+
avg:aws.elasticache.cache_hit_rate${local.query_filter} by {${var.query_organize_by_fields}}
119119
) >= ${var.hit_rate_threshold_critical}
120120
END
121121

@@ -144,7 +144,7 @@ resource "datadog_monitor" "hit_rate_anomaly" {
144144

145145
query = <<END
146146
avg(${var.hit_rate_evaluation_window}):anomalies(
147-
avg:aws.elasticache.cache_hit_rate${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}, 'agile', ${var.hit_rate_anomaly_deviations},
147+
avg:aws.elasticache.cache_hit_rate${local.query_filter} by {${var.query_organize_by_fields}}, 'agile', ${var.hit_rate_anomaly_deviations},
148148
direction='below', count_default_zero='true',
149149
seasonality='${var.hit_rate_anomaly_seasonality}'
150150
) >= ${var.hit_rate_anomaly_threshold_critical}
@@ -174,7 +174,7 @@ resource "datadog_monitor" "max_connections" {
174174

175175
query = <<END
176176
max(${var.max_connections_evaluation_window}):(
177-
avg:aws.elasticache.curr_connections${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}
177+
avg:aws.elasticache.curr_connections${local.query_filter} by {${var.query_organize_by_fields}}
178178
) >= ${var.max_connections_threshold_critical}
179179
END
180180

@@ -203,7 +203,7 @@ resource "datadog_monitor" "swap_usage" {
203203

204204
query = <<END
205205
max(${var.swap_usage_evaluation_window}):(
206-
avg:aws.elasticache.swap_usage${local.query_filter} by {cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed}
206+
avg:aws.elasticache.swap_usage${local.query_filter} by {${var.query_organize_by_fields}}
207207
) <= ${var.swap_usage_threshold_critical}
208208
END
209209

aws/elasticache/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ variable "base_tags" {
1313
type = list(string)
1414
}
1515

16+
variable "query_organize_by_fields" {
17+
default = "cachenodeid,cacheclusterid,region,aws_account,env,datadog_managed"
18+
description = "Fields (in order) by which to organize the results of the monitor queries for this module. An example modification would be to add replication_group to the front of the default value."
19+
}
20+
1621
########################################
1722
# Node CPU Utilization
1823
########################################

0 commit comments

Comments
 (0)