Skip to content

Commit

Permalink
feat(applicationautoscaling): add missing PredefinedMetricType enum v…
Browse files Browse the repository at this point in the history
…alues (#29066)

There are three `PredefinedMetricType` values missing from the enum:

* SageMakerVariantProvisionedConcurrencyUtilization
* SageMakerInferenceComponentInvocationsPerCopy
* ElastiCacheDatabaseCapacityUsageCountedForEvictPercentage

https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html

Closes #29065.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
msambol committed Mar 1, 2024
1 parent 985c7e4 commit 63390e1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
17 changes: 17 additions & 0 deletions packages/aws-cdk-lib/aws-applicationautoscaling/README.md
Expand Up @@ -247,3 +247,20 @@ shardsScalableTarget.scaleToTrackMetric('ElastiCacheRedisShardsCPUUtilization',
predefinedMetric: appscaling.PredefinedMetric.ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION,
});
```

### SageMaker variant provisioned concurrency utilization with target value

```ts
const target = new appscaling.ScalableTarget(this, 'SageMakerVariantScalableTarget', {
serviceNamespace: appscaling.ServiceNamespace.SAGEMAKER,
scalableDimension: 'sagemaker:variant:DesiredProvisionedConcurrency',
minCapacity: 2,
maxCapacity: 10,
resourceId: 'endpoint/MyEndpoint/variant/MyVariant',
});

target.scaleToTrackMetric('SageMakerVariantProvisionedConcurrencyUtilization', {
targetValue: 0.9,
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_VARIANT_PROVISIONED_CONCURRENCY_UTILIZATION,
});
```
Expand Up @@ -254,6 +254,16 @@ export enum PredefinedMetric {
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
SAGEMAKER_VARIANT_INVOCATIONS_PER_INSTANCE = 'SageMakerVariantInvocationsPerInstance',
/**
* SAGEMAKER_VARIANT_PROVISIONED_CONCURRENCY_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
SAGEMAKER_VARIANT_PROVISIONED_CONCURRENCY_UTILIZATION = 'SageMakerVariantProvisionedConcurrencyUtilization',
/**
* SAGEMAKER_INFERENCE_COMPONENT_INVOCATIONS_PER_COPY
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
SAGEMAKER_INFERENCE_COMPONENT_INVOCATIONS_PER_COPY = 'SageMakerInferenceComponentInvocationsPerCopy',
/**
* ECS_SERVICE_AVERAGE_CPU_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
Expand All @@ -275,18 +285,23 @@ export enum PredefinedMetric {
*/
KAFKA_BROKER_STORAGE_UTILIZATION = 'KafkaBrokerStorageUtilization',
/**
* ELASTIC_CACHE_PRIMARY_ENGINE_CPU_UTILIZATION
* ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION = 'ElastiCachePrimaryEngineCPUUtilization',
/**
* ELASTIC_CACHE_REPLICA_ENGINE_CPU_UTILIZATION
* ELASTICACHE_REPLICA_ENGINE_CPU_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ELASTICACHE_REPLICA_ENGINE_CPU_UTILIZATION = 'ElastiCacheReplicaEngineCPUUtilization',
/**
* ELASTIC_CACHE_REPLICA_ENGINE_CPU_UTILIZATION
* ELASTICACHE_DATABASE_MEMORY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ELASTICACHE_DATABASE_MEMORY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE = 'ElastiCacheDatabaseMemoryUsageCountedForEvictPercentage',
/**
* ELASTICACHE_DATABASE_CAPACITY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ELASTICACHE_DATABASE_CAPACITY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE = 'ElastiCacheDatabaseCapacityUsageCountedForEvictPercentage',
}
Expand Up @@ -71,6 +71,26 @@ describe('target tracking', () => {
});
});

test('test setup target tracking on predefined metric for SAGEMAKER_VARIANT_PROVISIONED_CONCURRENCY_UTILIZATION', () => {
// GIVEN
const stack = new cdk.Stack();
const target = createScalableTarget(stack);

// WHEN
target.scaleToTrackMetric('Tracking', {
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_VARIANT_PROVISIONED_CONCURRENCY_UTILIZATION,
targetValue: 0.5,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
TargetTrackingScalingPolicyConfiguration: {
PredefinedMetricSpecification: { PredefinedMetricType: 'SageMakerVariantProvisionedConcurrencyUtilization' },
TargetValue: 0.5,
},
});
});

test('test setup target tracking on custom metric', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 63390e1

Please sign in to comment.