Amazon web services 如何将boto3 cloudwatch用于SageMaker提交的培训工作?
我已经从AWS SageMaker提交了一些培训工作。我想使用boto3 cloudwatch api获取要在jupyter笔记本中显示的cloudwatch数据,而不是使用cloudwatch UI 您可以使用CloudWatch GetMetricWidgetImage API将图形输入笔记本 下面是一个例子:Amazon web services 如何将boto3 cloudwatch用于SageMaker提交的培训工作?,amazon-web-services,boto3,amazon-cloudwatch,amazon-sagemaker,Amazon Web Services,Boto3,Amazon Cloudwatch,Amazon Sagemaker,我已经从AWS SageMaker提交了一些培训工作。我想使用boto3 cloudwatch api获取要在jupyter笔记本中显示的cloudwatch数据,而不是使用cloudwatch UI 您可以使用CloudWatch GetMetricWidgetImage API将图形输入笔记本 下面是一个例子: import boto3 from PIL import Image from io import BytesIO widget = '''{ "metrics": [
import boto3
from PIL import Image
from io import BytesIO
widget = '''{
"metrics": [
[ "namespace", "metricname", "dim1", "value1", "dim2", "value2", "dim3", "value3", { "stat": "Average", "id": "m0r0" } ]
],
"title": "Title of the graph",
"view": "timeSeries",
"stacked": false,
"width": 600,
"height": 400,
"start": "-PT3H",
"end": "P0D"
}'''
client = boto3.client('cloudwatch')
response = client.get_metric_widget_image(
MetricWidget=widget
)
Image.open(BytesIO(response['MetricWidgetImage']))
通过在CloudWatch控制台中打开所需的度量,单击Source
选项卡并选择底部的imageapi
视图,可以获得小部件定义。根据你的喜好调整宽度和高度
您还需要调整SageMaker执行角色的策略,以允许调用GetMetricWidgetImage。感谢您的回复。我在想。当我们调用get_metric_widget_image函数时,我们不需要传递培训工作的标题吗?让我看看我是否理解您的问题。您想获得sage maker图,如本教程底部所述:在jupyter笔记本中?如果是,您可以转到CloudWatch并复制完整的小部件定义,如答案中所述,或者您可以尝试动态构建小部件,这将需要知道培训工作的名称。