Skip to content

Commit

Permalink
LIME-1343 - Added FE Vital Signs logging
Browse files Browse the repository at this point in the history
Signed-off-by: ElliotMurphyGDS <[email protected]>
  • Loading branch information
ElliotMurphyGDS committed Jan 13, 2025
1 parent e581aa7 commit e4ffd71
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
73 changes: 73 additions & 0 deletions deploy/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,79 @@ Resources:
Period: 60
Stat: Sum

EventLoopDelayMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{($.eventLoopDelay = *)}"
MetricTransformations:
- MetricValue: $.eventLoopDelay
MetricName: EventLoopDelay
MetricNamespace: !Sub ${AWS::StackName}/LogMessages

EventLoopUtilizationIdleMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.eventLoopUtilization.idle = * }"
MetricTransformations:
- MetricValue: $.eventLoopUtilization.idle
MetricName: EventLoopUtilizationIdle
MetricNamespace: !Sub ${AWS::StackName}/LogMessages

EventLoopUtilizationActiveMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.eventLoopUtilization.active = * }"
MetricTransformations:
- MetricValue: $.eventLoopUtilization.active
MetricName: EventLoopUtilizationActive
MetricNamespace: !Sub ${AWS::StackName}/LogMessages

EventLoopUtilizationUtilizationMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.eventLoopUtilization.utilization = * }"
MetricTransformations:
- MetricValue: $.eventLoopUtilization.utilization
MetricName: EventLoopUtilizationUtilization
MetricNamespace: !Sub ${AWS::StackName}/LogMessages

RequestsPerSecondMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.requestsPerSecond.dynamic = * }"
MetricTransformations:
- MetricValue: $.requestsPerSecond.dynamic
MetricName: RequestsPerSecond
MetricNamespace: !Sub ${AWS::StackName}/LogMessages
Unit: Count/Second

AvgResponseTimeMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.avgResponseTime.dynamic = * }"
MetricTransformations:
- MetricValue: $.avgResponseTime.dynamic
MetricName: AvgResponseTime
MetricNamespace: !Sub ${AWS::StackName}/LogMessages
Unit: Count/Second

MaxConcurrentConnectionsMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Ref ECSAccessLogsGroup
FilterPattern: "{ $.maxConcurrentConnections = * }"
MetricTransformations:
- MetricValue: $.maxConcurrentConnections
MetricName: MaxConcurrentConnections
MetricNamespace: !Sub ${AWS::StackName}/LogMessages
Unit: Count

####################################################################
# #
# Alarm setup #
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@govuk-one-login/frontend-analytics": "2.0.1",
"@govuk-one-login/frontend-language-toggle": "1.1.0",
"@govuk-one-login/frontend-passthrough-headers": "1.1.1",
"@govuk-one-login/frontend-vital-signs": "0.0.4",
"axios": "1.6.1",
"cfenv": "1.2.4",
"connect-dynamodb": "3.0.3",
Expand Down
22 changes: 22 additions & 0 deletions src/app-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const {
} = require("@govuk-one-login/di-ipv-cri-common-express/src/lib/i18next");
// Common express relies on 0/1 strings
const showLanguageToggle = APP.LANGUAGE_TOGGLE_DISABLED === "true" ? "0" : "1";
const {
frontendVitalSignsInitFromApp,
} = require("@govuk-one-login/frontend-vital-signs");

const init = (app, router) => {
setAPIConfig({
Expand Down Expand Up @@ -88,6 +91,25 @@ const create = (setup) => {
"views"
],
middlewareSetupFn: (app) => {
frontendVitalSignsInitFromApp(app, {
interval: 60000,
logLevel: "info",
metrics: [
"requestsPerSecond",
"avgResponseTime",
"maxConcurrentConnections",
"eventLoopDelay",
"eventLoopUtilization",
],
staticPaths: [
/^\/assets\/.*/,
"/ga4-assets",
"/javascript",
"/javascripts",
"/images",
"/stylesheets",
],
});
app.use(setHeaders);
},
dev: true
Expand Down

0 comments on commit e4ffd71

Please sign in to comment.