diff --git a/deploy/template.yaml b/deploy/template.yaml index 6c948de..9096759 100644 --- a/deploy/template.yaml +++ b/deploy/template.yaml @@ -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 # diff --git a/package.json b/package.json index 6d69d61..e2265f9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/app-setup.js b/src/app-setup.js index 66db6b0..08180bc 100644 --- a/src/app-setup.js +++ b/src/app-setup.js @@ -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({ @@ -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