简体   繁体   English

我如何使用 boto3 在 AWS lambda 中获得最大并发执行数、最小值和平均值

[英]How do i get the maximum number of concurrent executions,minimum and average in AWS lambda using boto3

How do i get the maximum number of concurrent executions,minimum and average in AWS lambda using boto3 and cloudwatch?如何使用 boto3 和 cloudwatch 在 AWS lambda 中获得最大并发执行数、最小值和平均值?

I don't know what should i put in dimensions,period etc.我不知道我应该在尺寸、周期等中输入什么。

cloudwatch = boto3.client('cloudwatch',aws_access_key_id=awsaccesskey,
                      aws_secret_access_key=awssecretkey,
                      region_name=awsregion)

response = cloudwatch.get_metric_data(
    MetricDataQueries=[
        {
            'Id': 'string',
            'MetricStat': {
                'Metric': {
                    'Namespace': 'AWS/Lambda',
                    'MetricName': 'ConcurrentExecutions',
                    'Dimensions': [
                        {
                            "Name": "FunctionName",
                            "Value": "benchmark-hl7"
                        }
                    ]
                },
                'Period': 36000,
                'Stat': 'Average',
                'Unit': 'Bytes'
            },
        },
    ],
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime.now()
)

print(response)

The only notable issue in your code is that the units are incorrect .您的代码中唯一值得注意的问题是单位不正确 This will result in empty results.这将导致空结果。 The correct unit is Count , not Bytes .正确的单位是Count ,而不是Bytes Thus, it should be:因此,它应该是:

Unit': 'Count'

Also metrics retention is 15 months so you will not get any result dating back to 2015.此外,指标保留期为15 个月,因此您不会得到任何可追溯到 2015 年的结果。

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

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