Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
CloudWatch Alarm Percentage of errors API Gateway

I'm trying to setup and alarm in Cloudwatch using terraform. My alarm basically needs to check if there is more than 5% of 5xx errors in the gateway during 2 periods of 1 minute.

I've tried the following code but it's not working:

resource "aws_cloudwatch_metric_alarm" "gateway_error_rate" {
  alarm_name          = "gateway-errors"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  alarm_description   = "Gateway error rate has exceeded 5%"
  treat_missing_data  = "notBreaching"
  metric_name         = "5XXError"
  namespace           = "AWS/ApiGateway"
  period              = 60
  evaluation_periods  = 2
  threshold           = 5
  statistic           = "Average"
  unit                = "Percent"

  dimensions = {
    ApiName = "my-api"
    Stage = "dev"
  }
}

Even thee alert is deployed, the data is not displayed. Doing some tests I've noticed that apparently the unit "percent" is not accepted for this alarm.

Does anyone have an example in terraform or cloudformation on how to configure this type of alarms?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Based on the information provided in the comments by Marcin, I've found this info in the aws documentation:

The Average statistic represents the 5XXError error rate, namely, the total count of the 5XXError errors divided by the total number of requests during the period. The denominator corresponds to the Count metric (below).

My alarm configured in terraform looks as follow:

resource "aws_cloudwatch_metric_alarm" "gateway_error_rate" {
  alarm_name          = "gateway-errors"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  alarm_description   = "Gateway error rate has exceeded 5%"
  treat_missing_data  = "notBreaching"
  metric_name         = "5XXError"
  namespace           = "AWS/ApiGateway"
  period              = 60
  evaluation_periods  = 2
  threshold           = 0.05
  statistic           = "Average"
  unit                = "Count"

  dimensions = {
    ApiName = "my-api"
    Stage = "dev"
  }
}
over 4 years ago · Santiago Trujillo Denunciar

0

I am using this on CloudFormation and it is working fine, and I use SUM not "percent"

  ApiGateway5XXErrorAlarm:
    Type: 'AWS::CloudWatch::Alarm'
    Properties:
      AlarmDescription: 'Api Gateway server-side errors captured'
      Namespace: 'AWS/ApiGateway'
      MetricName: 5XXError
      Dimensions:
      - Name: ApiName
        Value: !Ref ApiGateway
      - Name: Stage
        Value: dev
      Statistic: Sum
      Period: 60
      EvaluationPeriods: 1
      Threshold: 1
      ComparisonOperator: GreaterThanOrEqualToThreshold
      AlarmActions:
      - !Ref Alerts
      TreatMissingData: notBreaching
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda