cloudposse / terraform-aws-elasticache-redis

Terraform module to provision an ElastiCache Redis Cluster
https://cloudposse.com/accelerate
Apache License 2.0
141 stars 244 forks source link

Cloudwatch alarms insufficient data #56

Closed chelomontilla closed 4 years ago

chelomontilla commented 4 years ago

I've created a redis without enabling the automatic_failover, only one node. The problem is that alarms at cloudwatch shows insufficient data. The configured dimension value for CacheClusterId in the alarm is "myredis" and if I see in cloudwatch the current metrics having data are in dimension value "myredis-001".

mukill commented 4 years ago

were you able to resolve this?

chelomontilla commented 4 years ago

No, still not

varunpalekar commented 4 years ago

+1

chrischildresssg commented 4 years ago

The module itself doesn't include necessary code to handle insufficient data. Both of the "aws_cloudwatch_metric_alarm" resources need to have the "treat_missing_data" argument presented, but do not.

For instance, the "cache_memory" alarm should look like this, with the "treat_missing_data" argument near the bottom:

resource "aws_cloudwatch_metric_alarm" "cache_memory" { count = var.enabled ? 1 : 0 alarm_name = "${module.label.id}-freeable-memory" alarm_description = "Redis cluster freeable memory" comparison_operator = "LessThanThreshold" evaluation_periods = "1" metric_name = "FreeableMemory" namespace = "AWS/ElastiCache" period = "60" statistic = "Average"

threshold = var.alarm_memory_threshold_bytes

dimensions = { CacheClusterId = module.label.id }

alarm_actions = var.alarm_actions ok_actions = var.ok_actions

treat_missing_data = var.treat_missing_data

depends_on = [aws_elasticache_replication_group.default] }

varunpalekar commented 4 years ago

I found the main problem, it's due to creating more than one node in cluster mode, and for single also we need to add node number. So may be a count with alarm and counting mechanism with module.label.id would solve the problem

dimensions = {
    CacheClusterId = module.label.id
}

I will also create an MR for this.