Skip to content

Commit

Permalink
fix: dashboard queries and logsinsights queries
Browse files Browse the repository at this point in the history
  • Loading branch information
marnixdessing committed Apr 7, 2023
1 parent 8fc6546 commit 8fc9e87
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions src/ApiStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}

/**
Expand Down Expand Up @@ -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',
}),
});

}

}
10 changes: 5 additions & 5 deletions src/DashboardStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
});
Expand Down Expand Up @@ -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)',
],
});
}
Expand Down

0 comments on commit 8fc9e87

Please sign in to comment.