Nidorino94
Nidorino94

Reputation: 163

Terraform Cloudwatch Alarms - Configuration of Dimensions

let's suppose I have this Alarm:

  resource "aws_cloudwatch_metric_alarm" "nlb_healthyhosts" {
  alarm_name          = "alarmname"
  comparison_operator = "LessThanThreshold"
  evaluation_periods  = "1"
  metric_name         = "HealthyHostCount"
  namespace           = "AWS/NetworkELB"
  period              = "60"
  statistic           = "Average"
  threshold           = var.logstash_servers_count
  alarm_description   = "Number of healthy nodes in Target Group"
  actions_enabled     = "true"
  alarm_actions       = [aws_sns_topic.sns.arn]
  ok_actions          = [aws_sns_topic.sns.arn]
  dimensions = {
    TargetGroup  = aws_lb_target_group.lb-tg.arn_suffix
    LoadBalancer = aws_lb.lb.arn_suffix
  }
}

Under dimensions, I see in the AWS Documentation that only a few dimensions for EC2 Instances available are ( like instance ID - etc .... ) . In my project, I am using a Tag called " Type " to categorize my instances to HTTP or APP instances. Is there any mean to create alarms based on those tags as dimensions ? Meaning creating alarms for instances with the TAG " Http " and alarms for instances Tagged as " App " . Thank you so much in advance. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html#ec2-cloudwatch-dimensions

Upvotes: 1

Views: 1887

Answers (1)

Marcin
Marcin

Reputation: 239000

You would have to create custom Metrics based on the default metrics provided by AWS. The custom metrics can have any dimension you want. Once you have the custom metrics defined, you can create alarms based on them.

Upvotes: 1

Related Questions