diff --git a/docs/Deployment.md b/docs/Deployment.md index d7ef23e0..d2c8d186 100644 --- a/docs/Deployment.md +++ b/docs/Deployment.md @@ -9,6 +9,7 @@ Steps: 4. Set the CLI to the correct deployment/build account to deploy to 5. run `npx cdk deploy -a cdk.out --all` 6. After deployment the application parameters and secrets should be configured as below. +7. Make sure the devirsivier ssm parameter has a random value ## Parameters diff --git a/src/ApiStack.ts b/src/ApiStack.ts index 8094f883..a03a9380 100644 --- a/src/ApiStack.ts +++ b/src/ApiStack.ts @@ -193,6 +193,12 @@ export class ApiStack extends Stack { methods: [apigatewayv2.HttpMethod.GET], }); + this.createCloudWatchInsightsQueries([ + loginFunction.lambda.logGroup, + logoutFunction.lambda.logGroup, + authFunction.lambda.logGroup, + issueFunction.lambda.logGroup, + ]); } /** @@ -287,4 +293,27 @@ export class ApiStack extends Stack { }); } + createCloudWatchInsightsQueries(logGroups: logs.ILogGroup[]) { + + new logs.QueryDefinition(this, 'error-logs-query', { + queryDefinitionName: 'Yivi/Erros in issue app', + logGroups, + queryString: new logs.QueryString({ + fields: ['@timestamp', '@message'], + filterStatements: ['@message like /ERROR/'], + sort: '@timestamp desc', + }), + }); + + new logs.QueryDefinition(this, 'all-logs-query', { + queryDefinitionName: 'Yivi/Logging in issue app', + logGroups, + queryString: new logs.QueryString({ + fields: ['@timestamp', '@message'], + sort: '@timestamp desc', + }), + }); + + } + } \ No newline at end of file diff --git a/src/DashboardStack.ts b/src/DashboardStack.ts index 1e0552df..9d122239 100644 --- a/src/DashboardStack.ts +++ b/src/DashboardStack.ts @@ -45,10 +45,10 @@ export class DashboardStack extends Stack { height: 12, logGroupNames: [logGroup], view: Visualization.TABLE, - queryLines: [ // not the best way to list this (however we are running into limitations of cloudwatch here) - 'fields gemeente', - 'filter not isempty(subject) and nr_of_issues_per_subject > 1', - 'stats count(subject) as nr_of_issues_per_subject by gemeente, subject', + queryLines: [ + 'filter not isempty(subject) and issueAttempt = 1', // Filter before count + 'stats count(subject) as nr_of_issues_per_subject by gemeente, subject', // count + 'filter nr_of_issues_per_subject > 1', // Filter after count 'sort gemeente', ], }); @@ -77,7 +77,7 @@ export class DashboardStack extends Stack { view: Visualization.LINE, queryLines: [ 'fields @message like /TICK\: BRP/ as brp, @message like /TICK\: DigiD/ as digid', - 'stats count(brp) as BRP, count(digid) as DigiD by bin(1h)', + 'stats sum(brp) as BRP, sum(digid) as DigiD by bin(1h)', ], }); }