简体   繁体   English

如何使用 boto3 启用 S3 请求指标

[英]How to enable S3 Request metrics using boto3

I need to enable Request metrics for AllRequests to S3 buckets using boto3.我需要使用boto3为 S3 存储桶启用 AllRequests 的请求指标。 Please help me with some hints on this.请帮我一些提示。

I think you want to use the put_bucket_metrics_configuration on the S3 client of boto3.我认为您想在boto3的 S3 客户端上使用 put_bucket_metrics_configuration。

response = client.put_bucket_metrics_configuration(
    Bucket='my-bucket',
    Id='metrics-config-id',
    MetricsConfiguration={
        'Id': 'metrics-config-id',
        'Filter': {
            'Prefix': 'my-prefix',
        }
    }
)

The Filter property can be excluded if you just want to enable metrics for everything in the bucket.如果您只想为存储桶中的所有内容启用指标,则可以排除Filter属性。 See the documentation, it also allows you to filter based on Tags and add multiple conditions.请参阅文档,它还允许您根据标签进行过滤并添加多个条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM