AWS::SageMaker::MonitoringSchedule - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::SageMaker::MonitoringSchedule

AWS::SageMaker::MonitoringSchedule 资源是 Amazon SageMaker 资源类型,它定期启动 SageMaker 处理作业,以监控为 SageMaker 终端节点捕获的数据。

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::SageMaker::MonitoringSchedule", "Properties" : { "CreationTime" : String, "EndpointName" : String, "FailureReason" : String, "LastModifiedTime" : String, "LastMonitoringExecutionSummary" : MonitoringExecutionSummary, "MonitoringScheduleArn" : String, "MonitoringScheduleConfig" : MonitoringScheduleConfig, "MonitoringScheduleName" : String, "MonitoringScheduleStatus" : String, "Tags" : [ Tag, ... ] } }

属性

CreationTime

监控计划的创建时间。

必需:否

类型:字符串

Update requires: No interruption

EndpointName

使用监控计划的终端节点的名称。

必需:否

类型:字符串

最高63

模式^[a-zA-Z0-9](-*[a-zA-Z0-9])*

Update requires: No interruption

FailureReason

包含监控作业失败的原因(如果监控作业失败)。

必需:否

类型:字符串

Update requires: No interruption

LastModifiedTime

上次修改监控计划的时间。

必需:否

类型:字符串

Update requires: No interruption

LastMonitoringExecutionSummary

描述上次要运行的执行(如果有)的元数据。

必需:否

类型MonitoringExecutionSummary

Update requires: No interruption

MonitoringScheduleArn

监控计划的 Amazon 资源名称 (ARN)。

必需:否

类型:字符串

最高256

模式.*

Update requires: No interruption

MonitoringScheduleConfig

指定监控计划和定义监控作业的配置对象。

必需:是

类型MonitoringScheduleConfig

Update requires: No interruption

MonitoringScheduleName

监控计划的名称。

必需:是

类型:字符串

最低1

最高63

模式^[a-zA-Z0-9](-*[a-zA-Z0-9])*$

Update requires: No interruption

MonitoringScheduleStatus

监控计划的状态。

必需:否

类型:字符串

允许的值Failed | Pending | Scheduled | Stopped

Update requires: No interruption

Tags

要应用于此资源的键值对的数组。

有关更多信息,请参阅标签

必需:否

类型Tag 的列表

Update requires: No interruption

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回监控计划的 Amazon 资源名称 (ARN)。

For more information about using the Ref function, see Ref.

示例

SageMaker MonitoringSchedule 示例

以下示例为 SageMaker 终端节点创建监控计划。

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Basic SageMaker Hosting entities to create a monitoring schedule", "Mappings": { "RegionMap": { "us-west-2": { "NullTransformer": "123456789012.dkr.ecr.us-west-2.amazonaws.com/mymodel:latest" }, "us-east-2": { "NullTransformer": "123456789012.dkr.ecr.us-east-2.amazonaws.com/mymodel:latest" }, "us-east-1": { "NullTransformer": "123456789012.dkr.ecr.us-east-1.amazonaws.com/mymodel:latest" }, "eu-west-1": { "NullTransformer": "123456789012.dkr.ecr.eu-west-1.amazonaws.com/mymodel:latest" }, "ap-northeast-1": { "NullTransformer": "123456789012.dkr.ecr.ap-northeast-1.amazonaws.com/mymodel:latest" }, "ap-northeast-2": { "NullTransformer": "123456789012.dkr.ecr.ap-northeast-2.amazonaws.com/mymodel:latest" }, "ap-southeast-2": { "NullTransformer": "123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/mymodel:latest" }, "eu-central-1": { "NullTransformer": "123456789012.dkr.ecr.eu-central-1.amazonaws.com/mymodel:latest" } } }, "Resources": { "Endpoint": { "Type": "AWS::SageMaker::Endpoint", "Properties": { "EndpointConfigName": null } }, "EndpointConfig": { "Type": "AWS::SageMaker::EndpointConfig", "Properties": { "ProductionVariants": [ { "InitialInstanceCount": 1, "InitialVariantWeight": 1, "InstanceType": "ml.t2.large", "ModelName": null, "VariantName": null } ] } }, "Model": { "Type": "AWS::SageMaker::Model", "Properties": { "PrimaryContainer": { "Image": null }, "ExecutionRoleArn": null } }, "ExecutionRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "sagemaker.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/", "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "*", "Resource": "*" } ] } } ] } }, "MonitoringScheduleExecutionRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "sagemaker.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "ManagedPolicyArns": [ { "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonSageMakerFullAccess" }, { "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonS3FullAccess" }, { "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" } ] } }, "MonitoringSchedule": { "Type": "AWS::SageMaker::MonitoringSchedule", "Properties": { "MonitoringScheduleConfig": { "MonitoringJobDefinition": { "MonitoringAppSpecification": { "ImageUri": { "Fn::Sub": "123456789012.dkr.ecr.${AWS::Partition}.amazonaws.com/sagemaker-model-monitor-analyzer:latest" } }, "MonitoringInputs": [ { "EndpointInput": { "EndpointName": { "Fn::ImportValue": "CanaryEndpointName" }, "LocalPath": "/opt/ml/processing/endpointdata" } } ], "MonitoringOutputConfig": { "MonitoringOutputs": [ { "S3Output": { "LocalPath": "/opt/ml/processing/localpath", "S3Uri": "s3://endpoint-data-capture/myEndpoint" } } ] }, "MonitoringResources": { "ClusterConfig": { "InstanceCount": 1, "InstanceType": "ml.m5.large", "VolumeSizeInGB": 50 } }, "RoleArn": null }, "ScheduleConfig": { "ScheduleExpression": "cron(0 * ? * * *)" } }, "MonitoringScheduleName": "BasicMonitoringSchedule" } } } }

YAML

--- AWSTemplateFormatVersion: '2010-09-09' Description: Basic SageMaker Hosting entities to create a monitoring schedule Description: "Basic Hosting entities test. We need models to create endpoint configs." Mappings: RegionMap: "us-west-2": "NullTransformer": "123456789012.dkr.ecr.us-west-2.amazonaws.com/mymodel:latest" "us-east-2": "NullTransformer": "123456789012.dkr.ecr.us-east-2.amazonaws.com/mymodel:latest" "us-east-1": "NullTransformer": "123456789012.dkr.ecr.us-east-1.amazonaws.com/mymodel:latest" "eu-west-1": "NullTransformer": "123456789012.dkr.ecr.eu-west-1.amazonaws.com/mymodel:latest" "ap-northeast-1": "NullTransformer": "123456789012.dkr.ecr.ap-northeast-1.amazonaws.com/mymodel:latest" "ap-northeast-2": "NullTransformer": "123456789012.dkr.ecr.ap-northeast-2.amazonaws.com/mymodel:latest" "ap-southeast-2": "NullTransformer": "123456789012.dkr.ecr.ap-southeast-2.amazonaws.com/mymodel:latest" "eu-central-1": "NullTransformer": "123456789012.dkr.ecr.eu-central-1.amazonaws.com/mymodel:latest" Resources: Endpoint: Type: "AWS::SageMaker::Endpoint" Properties: EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName EndpointConfig: Type: "AWS::SageMaker::EndpointConfig" Properties: ProductionVariants: - InitialInstanceCount: 1 InitialVariantWeight: 1.0 InstanceType: ml.t2.large ModelName: !GetAtt Model.ModelName VariantName: !GetAtt Model.ModelName Model: Type: "AWS::SageMaker::Model" Properties: PrimaryContainer: Image: !FindInMap [RegionMap, !Ref "AWS::Region", "NullTransformer"] ExecutionRoleArn: !GetAtt ExecutionRole.Arn ExecutionRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "sagemaker.amazonaws.com" Action: - "sts:AssumeRole" Path: "/" Policies: - PolicyName: "root" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: "*" Resource: "*" MonitoringScheduleExecutionRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - "sagemaker.amazonaws.com" Action: - "sts:AssumeRole" ManagedPolicyArns: - Fn::Sub: "arn:${AWS::Partition}:iam::aws:policy/AmazonSageMakerFullAccess" - Fn::Sub: "arn:${AWS::Partition}:iam::aws:policy/AmazonS3FullAccess" - Fn::Sub: "arn:${AWS::Partition}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" MonitoringSchedule: Type: AWS::SageMaker::MonitoringSchedule Properties: MonitoringScheduleConfig: MonitoringJobDefinition: MonitoringAppSpecification: ImageUri: Fn::Sub: "123456789012.dkr.ecr.${AWS::Partition}.amazonaws.com/sagemaker-model-monitor-analyzer:latest" MonitoringInputs: - EndpointInput: EndpointName: Fn::ImportValue: CanaryEndpointName LocalPath: "/opt/ml/processing/endpointdata" MonitoringOutputConfig: MonitoringOutputs: - S3Output: LocalPath: "/opt/ml/processing/localpath" S3Uri: s3://endpoint-data-capture/myEndpoint MonitoringResources: ClusterConfig: InstanceCount: 1 InstanceType: ml.m5.large VolumeSizeInGB: 50 RoleArn: !GetAtt MonitoringScheduleExecutionRole.Arn ScheduleConfig: ScheduleExpression: cron(0 * ? * * *) MonitoringScheduleName: BasicMonitoringSchedule