Skip to content

Commit

Permalink
Improve documentation and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aneesh Shukla committed Oct 20, 2023
1 parent dbce9aa commit 8983536
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export class ElastiCacheClusterMetricFactory {
/**
* @see https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.Redis.html
* Because Redis is single-threaded, you can use this metric to analyze the load of the Redis process itself.
* Note that you may want to monitor both Engine CPU Utilization as well as CPU Utilization as background
* processes can take up a significant portion of the CPU workload. This is especially important for
* hosts with 2 vCPUs or less
*/
metricMaxRedisEngineCpuUtilizationInPercent() {
return this.metricFactory.createMetric(
Expand Down
10 changes: 8 additions & 2 deletions lib/monitoring/aws-elasticache/ElastiCacheClusterMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export interface ElastiCacheClusterMonitoringOptions
readonly clusterType: ElastiCacheClusterType;

/**
* Add CPU usage alarm
* Add CPU usage alarm (useful for all clusterTypes including Redis)
*/
readonly addCpuUsageAlarm?: Record<string, UsageThreshold>;

/**
* Add redis engine CPU usage alarm
* Note: it is recommended to monitor CPU Utilization as well
* for hosts with two vCPUs or less
*/
readonly addRedisEngineCpuUsageAlarm?: Record<string, UsageThreshold>;

Expand Down Expand Up @@ -114,7 +116,7 @@ export class ElastiCacheClusterMonitoring extends Monitoring {
) {
super(scope, props);

this.elastiCacheClusterType = props.clusterType;
this.clusterType = props.clusterType;

const clusterType = capitalizeFirstLetterOnly(
ElastiCacheClusterType[props.clusterType]
Expand Down Expand Up @@ -173,6 +175,10 @@ export class ElastiCacheClusterMonitoring extends Monitoring {
this.addAlarm(createdAlarm);
}

if (props.addRedisEngineCpuUsageAlarm !== undefined && props.clusterType !== ElastiCacheClusterType.REDIS) {
throw new Error("It is only possible to alarm on Redis Engine CPU Usage for Redis clusters")
}

for (const disambiguator in props.addRedisEngineCpuUsageAlarm) {
const alarmProps = props.addRedisEngineCpuUsageAlarm[disambiguator];
const createdAlarm = this.usageAlarmFactory.addMaxCpuUsagePercentAlarm(
Expand Down

0 comments on commit 8983536

Please sign in to comment.