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

1040 add acu db alarm #42

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
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
127 changes: 63 additions & 64 deletions infra/lib/fhir-server-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,74 +318,73 @@ export class FHIRServerStack extends Stack {
dbClusterName: string,
alarmAction?: SnsAction
) {
const memoryMetric = dbCluster.metricFreeableMemory();
const memoryAlarm = memoryMetric.createAlarm(
this,
`${dbClusterName}FreeableMemoryAlarm`,
{
threshold: mbToBytes(150),
evaluationPeriods: 1,
comparisonOperator:
cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
}
);
alarmAction && memoryAlarm.addAlarmAction(alarmAction);
alarmAction && memoryAlarm.addOkAction(alarmAction);
const createAlarm = ({
name,
metric,
threshold,
evaluationPeriods,
comparisonOperator,
treatMissingData,
}: {
name: string;
metric: cloudwatch.Metric;
threshold: number;
evaluationPeriods: number;
comparisonOperator?: cloudwatch.ComparisonOperator;
treatMissingData?: cloudwatch.TreatMissingData;
}) => {
const alarm = metric.createAlarm(this, `${dbClusterName}${name}`, {
threshold,
evaluationPeriods,
comparisonOperator,
treatMissingData,
});
alarmAction && alarm.addAlarmAction(alarmAction);
alarmAction && alarm.addOkAction(alarmAction);
return alarm;
};

const storageMetric = dbCluster.metricFreeLocalStorage();
const storageAlarm = storageMetric.createAlarm(
this,
`${dbClusterName}FreeLocalStorageAlarm`,
{
threshold: mbToBytes(250),
evaluationPeriods: 1,
comparisonOperator:
cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
}
);
alarmAction && storageAlarm.addAlarmAction(alarmAction);
alarmAction && storageAlarm.addOkAction(alarmAction);
Comment on lines -336 to -349
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed b/c it's not applicable to Aurora serverless v2 - link, search for FreeLocalStorage.

createAlarm({
metric: dbCluster.metricFreeableMemory(),
name: "FreeableMemoryAlarm",
threshold: mbToBytes(150),
evaluationPeriods: 1,
comparisonOperator:
cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});

const cpuMetric = dbCluster.metricCPUUtilization();
const cpuAlarm = cpuMetric.createAlarm(
this,
`${dbClusterName}CPUUtilizationAlarm`,
{
threshold: 90, // percentage
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
}
);
alarmAction && cpuAlarm.addAlarmAction(alarmAction);
alarmAction && cpuAlarm.addOkAction(alarmAction);
createAlarm({
metric: dbCluster.metricCPUUtilization(),
name: "CPUUtilizationAlarm",
threshold: 90, // percentage
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});

const readIOPsMetric = dbCluster.metricVolumeReadIOPs();
const readAlarm = readIOPsMetric.createAlarm(
this,
`${dbClusterName}VolumeReadIOPsAlarm`,
{
threshold: 300_000, // IOPS
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
}
);
alarmAction && readAlarm.addAlarmAction(alarmAction);
alarmAction && readAlarm.addOkAction(alarmAction);
createAlarm({
metric: dbCluster.metricVolumeReadIOPs(),
name: "VolumeReadIOPsAlarm",
threshold: 300_000, // IOPS
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});

const writeIOPsMetric = dbCluster.metricVolumeWriteIOPs();
const writeAlarm = writeIOPsMetric.createAlarm(
this,
`${dbClusterName}VolumeWriteIOPsAlarm`,
{
threshold: 300_000, // IOPS
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
}
);
alarmAction && writeAlarm.addAlarmAction(alarmAction);
alarmAction && writeAlarm.addOkAction(alarmAction);
createAlarm({
metric: dbCluster.metricVolumeWriteIOPs(),
name: "VolumeWriteIOPsAlarm",
threshold: 300_000, // IOPS
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});

createAlarm({
metric: dbCluster.metricACUUtilization(),
name: "ACUUtilizationAlarm",
threshold: 80, // pct
evaluationPeriods: 1,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
});
}
}

Expand Down
Loading
Loading