AWS Compute Optimizer

2020/12/23 - AWS Compute Optimizer - 1 new 2 updated api methods

Changes  This release enables AWS Compute Optimizer to analyze and generate optimization recommendations for lambda functions.

GetLambdaFunctionRecommendations (new) Link ¶

Returns AWS Lambda function recommendations.

AWS Compute Optimizer generates recommendations for functions that meet a specific set of requirements. For more information, see the Supported resources and requirements in the AWS Compute Optimizer User Guide .

See also: AWS API Documentation

Request Syntax

client.get_lambda_function_recommendations(
    functionArns=[
        'string',
    ],
    accountIds=[
        'string',
    ],
    filters=[
        {
            'name': 'Finding'|'FindingReasonCode',
            'values': [
                'string',
            ]
        },
    ],
    nextToken='string',
    maxResults=123
)
type functionArns

list

param functionArns

The Amazon Resource Name (ARN) of the functions for which to return recommendations.

You can specify a qualified or unqualified ARN. If you specify an unqualified ARN without a function version suffix, Compute Optimizer will return recommendations for the latest ( $LATEST ) version of the function. If you specify a qualified ARN with a version suffix, Compute Optimizer will return recommendations for the specified function version. For more information about using function versions, see Using versions in the AWS Lambda Developer Guide .

  • (string) --

type accountIds

list

param accountIds

The IDs of the AWS accounts for which to return function recommendations.

If your account is the management account of an organization, use this parameter to specify the member accounts for which you want to return function recommendations.

Only one account ID can be specified per request.

  • (string) --

type filters

list

param filters

An array of objects that describe a filter that returns a more specific list of function recommendations.

  • (dict) --

    Describes a filter that returns a more specific list of AWS Lambda function recommendations.

    • name (string) --

      The name of the filter.

      Specify Finding to return recommendations with a specific finding classification (e.g., NotOptimized ).

      Specify FindingReasonCode to return recommendations with a specific finding reason code (e.g., MemoryUnderprovisioned ).

    • values (list) --

      The value of the filter.

      The valid values for this parameter are as follows, depending on what you specify for the name parameter:

      • Specify Optimized , NotOptimized , or Unavailable if you specified the name parameter as Finding .

      • Specify MemoryOverprovisioned , MemoryUnderprovisioned , InsufficientData , or Inconclusive if you specified the name parameter as FindingReasonCode .

      • (string) --

type nextToken

string

param nextToken

The token to advance to the next page of function recommendations.

type maxResults

integer

param maxResults

The maximum number of function recommendations to return with a single request.

To retrieve the remaining results, make another request with the returned NextToken value.

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'lambdaFunctionRecommendations': [
        {
            'functionArn': 'string',
            'functionVersion': 'string',
            'accountId': 'string',
            'currentMemorySize': 123,
            'numberOfInvocations': 123,
            'utilizationMetrics': [
                {
                    'name': 'Duration'|'Memory',
                    'statistic': 'Maximum'|'Average',
                    'value': 123.0
                },
            ],
            'lookbackPeriodInDays': 123.0,
            'lastRefreshTimestamp': datetime(2015, 1, 1),
            'finding': 'Optimized'|'NotOptimized'|'Unavailable',
            'findingReasonCodes': [
                'MemoryOverprovisioned'|'MemoryUnderprovisioned'|'InsufficientData'|'Inconclusive',
            ],
            'memorySizeRecommendationOptions': [
                {
                    'rank': 123,
                    'memorySize': 123,
                    'projectedUtilizationMetrics': [
                        {
                            'name': 'Duration',
                            'statistic': 'LowerBound'|'UpperBound'|'Expected',
                            'value': 123.0
                        },
                    ]
                },
            ]
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      The token to use to advance to the next page of function recommendations.

      This value is null when there are no more pages of function recommendations to return.

    • lambdaFunctionRecommendations (list) --

      An array of objects that describe function recommendations.

      • (dict) --

        Describes an AWS Lambda function recommendation.

        • functionArn (string) --

          The Amazon Resource Name (ARN) of the current function.

        • functionVersion (string) --

          The version number of the current function.

        • accountId (string) --

          The AWS account ID of the function.

        • currentMemorySize (integer) --

          The amount of memory, in MB, that's allocated to the current function.

        • numberOfInvocations (integer) --

          The number of times your function code was executed during the look-back period.

        • utilizationMetrics (list) --

          An array of objects that describe the utilization metrics of the function.

          • (dict) --

            Describes a utilization metric of an AWS Lambda function.

            • name (string) --

              The name of the utilization metric.

            • statistic (string) --

              The statistic of the utilization metric.

            • value (float) --

              The value of the utilization metric.

        • lookbackPeriodInDays (float) --

          The number of days for which utilization metrics were analyzed for the function.

        • lastRefreshTimestamp (datetime) --

          The time stamp of when the function recommendation was last refreshed.

        • finding (string) --

          The finding classification for the function.

          Findings for functions include:

          • Optimized — The function is correctly provisioned to run your workload based on its current configuration and its utilization history. This finding classification does not include finding reason codes.

          • NotOptimized — The function is performing at a higher level (over-provisioned) or at a lower level (under-provisioned) than required for your workload because its current configuration is not optimal. Over-provisioned resources might lead to unnecessary infrastructure cost, and under-provisioned resources might lead to poor application performance. This finding classification can include the MemoryUnderprovisioned and MemoryUnderprovisioned finding reason codes.

          • Unavailable — Compute Optimizer was unable to generate a recommendation for the function. This could be because the function has not accumulated sufficient metric data, or the function does not qualify for a recommendation. This finding classification can include the InsufficientData and Inconclusive finding reason codes.

          Note

          Functions with a finding of unavailable are not returned unless you specify the filter parameter with a value of Unavailable in your GetLambdaFunctionRecommendations request.

        • findingReasonCodes (list) --

          The reason for the finding classification of the function.

          Note

          Functions that have a finding classification of Optimized don't have a finding reason code.

          Reason codes include:

          • MemoryOverprovisioned — The function is over-provisioned when its memory configuration can be sized down while still meeting the performance requirements of your workload. An over-provisioned function might lead to unnecessary infrastructure cost. This finding reason code is part of the NotOptimized finding classification.

          • MemoryUnderprovisioned — The function is under-provisioned when its memory configuration doesn't meet the performance requirements of the workload. An under-provisioned function might lead to poor application performance. This finding reason code is part of the NotOptimized finding classification.

          • InsufficientData — The function does not have sufficient metric data for Compute Optimizer to generate a recommendation. For more information, see the Supported resources and requirements in the AWS Compute Optimizer User Guide . This finding reason code is part of the Unavailable finding classification.

          • Inconclusive — The function does not qualify for a recommendation, or there was an internal error. This finding reason code is part of the Unavailable finding classification.

          • (string) --

        • memorySizeRecommendationOptions (list) --

          An array of objects that describe the memory configuration recommendation options for the function.

          • (dict) --

            Describes a recommendation option for an AWS Lambda function.

            • rank (integer) --

              The rank of the function recommendation option.

              The top recommendation option is ranked as 1 .

            • memorySize (integer) --

              The memory size, in MB, of the function recommendation option.

            • projectedUtilizationMetrics (list) --

              An array of objects that describe the projected utilization metrics of the function recommendation option.

              • (dict) --

                Describes a projected utilization metric of an AWS Lambda function recommendation option.

                • name (string) --

                  The name of the projected utilization metric.

                • statistic (string) --

                  The statistic of the projected utilization metric.

                • value (float) --

                  The values of the projected utilization metrics.

GetEC2InstanceRecommendations (updated) Link ¶
Changes (response)
{'instanceRecommendations': {'recommendationSources': {'recommendationSourceType': {'LambdaFunction'}}}}

Returns Amazon EC2 instance recommendations.

AWS Compute Optimizer generates recommendations for Amazon Elastic Compute Cloud (Amazon EC2) instances that meet a specific set of requirements. For more information, see the Supported resources and requirements in the AWS Compute Optimizer User Guide .

See also: AWS API Documentation

Request Syntax

client.get_ec2_instance_recommendations(
    instanceArns=[
        'string',
    ],
    nextToken='string',
    maxResults=123,
    filters=[
        {
            'name': 'Finding'|'RecommendationSourceType',
            'values': [
                'string',
            ]
        },
    ],
    accountIds=[
        'string',
    ]
)
type instanceArns

list

param instanceArns

The Amazon Resource Name (ARN) of the instances for which to return recommendations.

  • (string) --

type nextToken

string

param nextToken

The token to advance to the next page of instance recommendations.

type maxResults

integer

param maxResults

The maximum number of instance recommendations to return with a single request.

To retrieve the remaining results, make another request with the returned NextToken value.

type filters

list

param filters

An array of objects that describe a filter that returns a more specific list of instance recommendations.

  • (dict) --

    Describes a filter that returns a more specific list of recommendations.

    This filter is used with the GetAutoScalingGroupRecommendations and GetEC2InstanceRecommendations actions.

    • name (string) --

      The name of the filter.

      Specify Finding to return recommendations with a specific finding classification (e.g., Overprovisioned ).

      Specify RecommendationSourceType to return recommendations of a specific resource type (e.g., AutoScalingGroup ).

    • values (list) --

      The value of the filter.

      The valid values for this parameter are as follows, depending on what you specify for the name parameter and the resource type that you wish to filter results for:

      • Specify Optimized or NotOptimized if you specified the name parameter as Finding and you want to filter results for Auto Scaling groups.

      • Specify Underprovisioned , Overprovisioned , or Optimized if you specified the name parameter as Finding and you want to filter results for EC2 instances.

      • Specify Ec2Instance or AutoScalingGroup if you specified the name parameter as RecommendationSourceType .

      • (string) --

type accountIds

list

param accountIds

The IDs of the AWS accounts for which to return instance recommendations.

If your account is the management account of an organization, use this parameter to specify the member accounts for which you want to return instance recommendations.

Only one account ID can be specified per request.

  • (string) --

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'instanceRecommendations': [
        {
            'instanceArn': 'string',
            'accountId': 'string',
            'instanceName': 'string',
            'currentInstanceType': 'string',
            'finding': 'Underprovisioned'|'Overprovisioned'|'Optimized'|'NotOptimized',
            'utilizationMetrics': [
                {
                    'name': 'Cpu'|'Memory'|'EBS_READ_OPS_PER_SECOND'|'EBS_WRITE_OPS_PER_SECOND'|'EBS_READ_BYTES_PER_SECOND'|'EBS_WRITE_BYTES_PER_SECOND',
                    'statistic': 'Maximum'|'Average',
                    'value': 123.0
                },
            ],
            'lookBackPeriodInDays': 123.0,
            'recommendationOptions': [
                {
                    'instanceType': 'string',
                    'projectedUtilizationMetrics': [
                        {
                            'name': 'Cpu'|'Memory'|'EBS_READ_OPS_PER_SECOND'|'EBS_WRITE_OPS_PER_SECOND'|'EBS_READ_BYTES_PER_SECOND'|'EBS_WRITE_BYTES_PER_SECOND',
                            'statistic': 'Maximum'|'Average',
                            'value': 123.0
                        },
                    ],
                    'performanceRisk': 123.0,
                    'rank': 123
                },
            ],
            'recommendationSources': [
                {
                    'recommendationSourceArn': 'string',
                    'recommendationSourceType': 'Ec2Instance'|'AutoScalingGroup'|'EbsVolume'|'LambdaFunction'
                },
            ],
            'lastRefreshTimestamp': datetime(2015, 1, 1)
        },
    ],
    'errors': [
        {
            'identifier': 'string',
            'code': 'string',
            'message': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      The token to use to advance to the next page of instance recommendations.

      This value is null when there are no more pages of instance recommendations to return.

    • instanceRecommendations (list) --

      An array of objects that describe instance recommendations.

      • (dict) --

        Describes an Amazon EC2 instance recommendation.

        • instanceArn (string) --

          The Amazon Resource Name (ARN) of the current instance.

        • accountId (string) --

          The AWS account ID of the instance.

        • instanceName (string) --

          The name of the current instance.

        • currentInstanceType (string) --

          The instance type of the current instance.

        • finding (string) --

          The finding classification for the instance.

          Findings for instances include:

          • Underprovisioned —An instance is considered under-provisioned when at least one specification of your instance, such as CPU, memory, or network, does not meet the performance requirements of your workload. Under-provisioned instances may lead to poor application performance.

          • Overprovisioned —An instance is considered over-provisioned when at least one specification of your instance, such as CPU, memory, or network, can be sized down while still meeting the performance requirements of your workload, and no specification is under-provisioned. Over-provisioned instances may lead to unnecessary infrastructure cost.

          • Optimized —An instance is considered optimized when all specifications of your instance, such as CPU, memory, and network, meet the performance requirements of your workload and is not over provisioned. An optimized instance runs your workloads with optimal performance and infrastructure cost. For optimized resources, AWS Compute Optimizer might recommend a new generation instance type.

        • utilizationMetrics (list) --

          An array of objects that describe the utilization metrics of the instance.

          • (dict) --

            Describes a utilization metric of a resource, such as an Amazon EC2 instance.

            Compare the utilization metric data of your resource against its projected utilization metric data to determine the performance difference between your current resource and the recommended option.

            • name (string) --

              The name of the utilization metric.

              The following utilization metrics are available:

              • Cpu - The percentage of allocated EC2 compute units that are currently in use on the instance. This metric identifies the processing power required to run an application on the instance. Depending on the instance type, tools in your operating system can show a lower percentage than CloudWatch when the instance is not allocated a full processor core. Units: Percent

              • Memory - The percentage of memory that is currently in use on the instance. This metric identifies the amount of memory required to run an application on the instance. Units: Percent

              Note

              The Memory metric is returned only for resources that have the unified CloudWatch agent installed on them. For more information, see Enabling Memory Utilization with the CloudWatch Agent.

              • EBS_READ_OPS_PER_SECOND - The completed read operations from all EBS volumes attached to the instance in a specified period of time. Unit: Count

              • EBS_WRITE_OPS_PER_SECOND - The completed write operations to all EBS volumes attached to the instance in a specified period of time. Unit: Count

              • EBS_READ_BYTES_PER_SECOND - The bytes read from all EBS volumes attached to the instance in a specified period of time. Unit: Bytes

              • EBS_WRITE_BYTES_PER_SECOND - The bytes written to all EBS volumes attached to the instance in a specified period of time. Unit: Bytes

            • statistic (string) --

              The statistic of the utilization metric.

              The following statistics are available:

              • Average - This is the value of Sum / SampleCount during the specified period, or the average value observed during the specified period.

              • Maximum - The highest value observed during the specified period. Use this value to determine high volumes of activity for your application.

            • value (float) --

              The value of the utilization metric.

        • lookBackPeriodInDays (float) --

          The number of days for which utilization metrics were analyzed for the instance.

        • recommendationOptions (list) --

          An array of objects that describe the recommendation options for the instance.

          • (dict) --

            Describes a recommendation option for an Amazon EC2 instance.

            • instanceType (string) --

              The instance type of the instance recommendation.

            • projectedUtilizationMetrics (list) --

              An array of objects that describe the projected utilization metrics of the instance recommendation option.

              Note

              The Cpu and Memory metrics are the only projected utilization metrics returned. Additionally, the Memory metric is returned only for resources that have the unified CloudWatch agent installed on them. For more information, see Enabling Memory Utilization with the CloudWatch Agent.

              • (dict) --

                Describes a utilization metric of a resource, such as an Amazon EC2 instance.

                Compare the utilization metric data of your resource against its projected utilization metric data to determine the performance difference between your current resource and the recommended option.

                • name (string) --

                  The name of the utilization metric.

                  The following utilization metrics are available:

                  • Cpu - The percentage of allocated EC2 compute units that are currently in use on the instance. This metric identifies the processing power required to run an application on the instance. Depending on the instance type, tools in your operating system can show a lower percentage than CloudWatch when the instance is not allocated a full processor core. Units: Percent

                  • Memory - The percentage of memory that is currently in use on the instance. This metric identifies the amount of memory required to run an application on the instance. Units: Percent

                  Note

                  The Memory metric is returned only for resources that have the unified CloudWatch agent installed on them. For more information, see Enabling Memory Utilization with the CloudWatch Agent.

                  • EBS_READ_OPS_PER_SECOND - The completed read operations from all EBS volumes attached to the instance in a specified period of time. Unit: Count

                  • EBS_WRITE_OPS_PER_SECOND - The completed write operations to all EBS volumes attached to the instance in a specified period of time. Unit: Count

                  • EBS_READ_BYTES_PER_SECOND - The bytes read from all EBS volumes attached to the instance in a specified period of time. Unit: Bytes

                  • EBS_WRITE_BYTES_PER_SECOND - The bytes written to all EBS volumes attached to the instance in a specified period of time. Unit: Bytes

                • statistic (string) --

                  The statistic of the utilization metric.

                  The following statistics are available:

                  • Average - This is the value of Sum / SampleCount during the specified period, or the average value observed during the specified period.

                  • Maximum - The highest value observed during the specified period. Use this value to determine high volumes of activity for your application.

                • value (float) --

                  The value of the utilization metric.

            • performanceRisk (float) --

              The performance risk of the instance recommendation option.

              Performance risk is the likelihood of the recommended instance type not meeting the performance requirement of your workload.

              The lowest performance risk is categorized as 0 , and the highest as 5 .

            • rank (integer) --

              The rank of the instance recommendation option.

              The top recommendation option is ranked as 1 .

        • recommendationSources (list) --

          An array of objects that describe the source resource of the recommendation.

          • (dict) --

            Describes the source of a recommendation, such as an Amazon EC2 instance or Auto Scaling group.

            • recommendationSourceArn (string) --

              The Amazon Resource Name (ARN) of the recommendation source.

            • recommendationSourceType (string) --

              The resource type of the recommendation source.

        • lastRefreshTimestamp (datetime) --

          The time stamp of when the instance recommendation was last refreshed.

    • errors (list) --

      An array of objects that describe errors of the request.

      For example, an error is returned if you request recommendations for an instance of an unsupported instance family.

      • (dict) --

        Describes an error experienced when getting recommendations.

        For example, an error is returned if you request recommendations for an unsupported Auto Scaling group, or if you request recommendations for an instance of an unsupported instance family.

        • identifier (string) --

          The ID of the error.

        • code (string) --

          The error code.

        • message (string) --

          The message, or reason, for the error.

GetRecommendationSummaries (updated) Link ¶
Changes (response)
{'recommendationSummaries': {'recommendationResourceType': {'LambdaFunction'},
                             'summaries': {'reasonCodeSummaries': [{'name': 'MemoryOverprovisioned '
                                                                            '| '
                                                                            'MemoryUnderprovisioned',
                                                                    'value': 'double'}]}}}

Returns the optimization findings for an account.

For example, it returns the number of Amazon EC2 instances in an account that are under-provisioned, over-provisioned, or optimized. It also returns the number of Auto Scaling groups in an account that are not optimized, or optimized.

See also: AWS API Documentation

Request Syntax

client.get_recommendation_summaries(
    accountIds=[
        'string',
    ],
    nextToken='string',
    maxResults=123
)
type accountIds

list

param accountIds

The IDs of the AWS accounts for which to return recommendation summaries.

If your account is the management account of an organization, use this parameter to specify the member accounts for which you want to return recommendation summaries.

Only one account ID can be specified per request.

  • (string) --

type nextToken

string

param nextToken

The token to advance to the next page of recommendation summaries.

type maxResults

integer

param maxResults

The maximum number of recommendation summaries to return with a single request.

To retrieve the remaining results, make another request with the returned NextToken value.

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'recommendationSummaries': [
        {
            'summaries': [
                {
                    'name': 'Underprovisioned'|'Overprovisioned'|'Optimized'|'NotOptimized',
                    'value': 123.0,
                    'reasonCodeSummaries': [
                        {
                            'name': 'MemoryOverprovisioned'|'MemoryUnderprovisioned',
                            'value': 123.0
                        },
                    ]
                },
            ],
            'recommendationResourceType': 'Ec2Instance'|'AutoScalingGroup'|'EbsVolume'|'LambdaFunction',
            'accountId': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      The token to use to advance to the next page of recommendation summaries.

      This value is null when there are no more pages of recommendation summaries to return.

    • recommendationSummaries (list) --

      An array of objects that summarize a recommendation.

      • (dict) --

        A summary of a recommendation.

        • summaries (list) --

          An array of objects that describe a recommendation summary.

          • (dict) --

            The summary of a recommendation.

            • name (string) --

              The finding classification of the recommendation.

            • value (float) --

              The value of the recommendation summary.

            • reasonCodeSummaries (list) --

              An array of objects that summarize a finding reason code.

              • (dict) --

                A summary of a finding reason code.

                • name (string) --

                  The name of the finding reason code.

                • value (float) --

                  The value of the finding reason code summary.

        • recommendationResourceType (string) --

          The resource type of the recommendation.

        • accountId (string) --

          The AWS account ID of the recommendation summary.