Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric Push API: Only alarm on 2xx errors #2655

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions handlers/metric-push-api/cfn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ Parameters:
- PROD
- CODE

Conditions:
CreateProdMonitoring: !Equals [ !Ref Stage, PROD ]
Comment on lines -12 to -13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is to update it to have the alarm in PROD and CODE, but we just don't trigger in CODE.
I personally think that makes it easier to test so I approve 👍 even with the extra clutter in the AWS console.


Mappings:
StageMap:
CODE:
ApiName: metric-push-api-api-CODE
DomainName: metric-push-api-code.support.guardianapis.com
AlarmActionsEnabled: FALSE
PROD:
ApiName: metric-push-api-api-PROD
DomainName: metric-push-api-prod.support.guardianapis.com
AlarmActionsEnabled: TRUE
Constants:
Alarm:
Process: Follow the process in https://docs.google.com/document/d/1_3El3cly9d7u_jPgTcRjLxmdG2e919zCLvmcFCLOYAk/edit
Expand Down Expand Up @@ -122,10 +121,10 @@ Resources:

5xxApiAlarm:
Type: AWS::CloudWatch::Alarm
Condition: CreateProdMonitoring
Properties:
AlarmActions:
- !Sub arn:aws:sns:${AWS::Region}:${AWS::AccountId}:alarms-handler-topic-${Stage}
ActionsEnabled: !FindInMap [StageMap, !Ref Stage, AlarmActionsEnabled]
AlarmName: !Join
- ' '
- - !FindInMap [ Constants, Alarm, Urgent ]
Expand All @@ -148,10 +147,10 @@ Resources:

HighClientSideErrorRateAlarm:
Type: AWS::CloudWatch::Alarm
Condition: CreateProdMonitoring
Properties:
AlarmActions:
- !Sub arn:aws:sns:${AWS::Region}:${AWS::AccountId}:alarms-handler-topic-${Stage}
ActionsEnabled: !FindInMap [StageMap, !Ref Stage, AlarmActionsEnabled]
AlarmName: !Join
- ' '
- - !FindInMap [ Constants, Alarm, Urgent ]
Expand All @@ -162,17 +161,46 @@ Resources:
- - 'Impact - some or all browsers are failing to render support client side pages. Log in to Sentry to see these errors: https://the-guardian.sentry.io/discover/results/?project=1213654&query=%22Fatal%20error%20rendering%20page%22&queryDataset=error-events&sort=-count&statsPeriod=24h'
- !FindInMap [ Constants, Alarm, Process ]
- !FindInMap [StageMap, !Ref Stage, ApiName]
MetricName: Count
Namespace: AWS/ApiGateway
Dimensions:
- Name: ApiName
Value: !FindInMap [StageMap, !Ref Stage, ApiName]
Metrics:
- Id: mtotal2xx
Expression: 'mtotalcount - (m5xxcount + m4xxcount)'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does seem sparse that we get so few metrics to look at comapred with what Load balancers have.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I know! It's surprising we have to derive this ourselves.

- Id: mtotalcount
ReturnData: false
MetricStat:
Period: 60
Stat: Sum
Metric:
Namespace: AWS/ApiGateway
MetricName: Count
Dimensions:
- Name: ApiName
Value: !FindInMap [StageMap, !Ref Stage, ApiName]
- Id: m5xxcount
ReturnData: false
MetricStat:
Period: 60
Stat: Sum
Metric:
Namespace: AWS/ApiGateway
MetricName: 5XXError
Dimensions:
- Name: ApiName
Value: !FindInMap [StageMap, !Ref Stage, ApiName]
- Id: m4xxcount
ReturnData: false
MetricStat:
Period: 60
Stat: Sum
Metric:
Namespace: AWS/ApiGateway
MetricName: 4XXError
Dimensions:
- Name: ApiName
Value: !FindInMap [StageMap, !Ref Stage, ApiName]
ComparisonOperator: GreaterThanOrEqualToThreshold
Threshold: 2
DatapointsToAlarm: 3
Period: 60
EvaluationPeriods: 5
Statistic: Sum
TreatMissingData: notBreaching
DependsOn:
- MetricPushAPI
Loading