기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
an AWS SDK 또는 CLIDescribeScalingActivities
와 함께 사용
다음 코드 예제는 DescribeScalingActivities
의 사용 방법을 보여 줍니다.
작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.
- .NET
-
- AWS SDK for .NET
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. /// <summary> /// Retrieve a list of the Amazon EC2 Auto Scaling activities for an /// Amazon EC2 Auto Scaling group. /// </summary> /// <param name="groupName">The name of the Amazon EC2 Auto Scaling group.</param> /// <returns>A list of Amazon EC2 Auto Scaling activities.</returns> public async Task<List<Amazon.AutoScaling.Model.Activity>> DescribeScalingActivitiesAsync( string groupName) { var scalingActivitiesRequest = new DescribeScalingActivitiesRequest { AutoScalingGroupName = groupName, MaxRecords = 10, }; var response = await _amazonAutoScaling.DescribeScalingActivitiesAsync(scalingActivitiesRequest); return response.Activities; }
-
API 세부 정보는 DescribeScalingActivities AWS SDK for .NET 참조의 API를 참조하세요.
-
- C++
-
- C++ SDK
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::AutoScaling::AutoScalingClient autoScalingClient(clientConfig); Aws::AutoScaling::Model::DescribeScalingActivitiesRequest request; request.SetAutoScalingGroupName(groupName); Aws::Vector<Aws::AutoScaling::Model::Activity> allActivities; Aws::String nextToken; // Used for pagination; do { if (!nextToken.empty()) { request.SetNextToken(nextToken); } Aws::AutoScaling::Model::DescribeScalingActivitiesOutcome outcome = autoScalingClient.DescribeScalingActivities(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::AutoScaling::Model::Activity> &activities = outcome.GetResult().GetActivities(); allActivities.insert(allActivities.end(), activities.begin(), activities.end()); nextToken = outcome.GetResult().GetNextToken(); } else { std::cerr << "Error with AutoScaling::DescribeScalingActivities. " << outcome.GetError().GetMessage() << std::endl; } } while (!nextToken.empty()); std::cout << "Found " << allActivities.size() << " activities." << std::endl; std::cout << "Activities are ordered with the most recent first." << std::endl; for (const Aws::AutoScaling::Model::Activity &activity: allActivities) { std::cout << activity.GetDescription() << std::endl; std::cout << activity.GetDetails() << std::endl; }
-
API 세부 정보는 DescribeScalingActivities AWS SDK for C++ 참조의 API를 참조하세요.
-
- CLI
-
- AWS CLI
-
예 1: 지정된 그룹에 대한 크기 조정 활동을 설명하는 방법
이 예시에서는 지정된 Auto Scaling 그룹에 대한 크기 조정 활동을 설명합니다.
aws autoscaling describe-scaling-activities \ --auto-scaling-group-name
my-asg
출력:
{ "Activities": [ { "ActivityId": "f9f2d65b-f1f2-43e7-b46d-d86756459699", "Description": "Launching a new EC2 instance: i-0d44425630326060f", "AutoScalingGroupName": "my-asg", "Cause": "At 2020-10-30T19:35:51Z a user request update of AutoScalingGroup constraints to min: 0, max: 16, desired: 16 changing the desired capacity from 0 to 16. At 2020-10-30T19:36:07Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 16.", "StartTime": "2020-10-30T19:36:09.766Z", "EndTime": "2020-10-30T19:36:41Z", "StatusCode": "Successful", "Progress": 100, "Details": "{\"Subnet ID\":\"subnet-5ea0c127\",\"Availability Zone\":\"us-west-2b\"}" } ] }
자세한 내용은 Amazon Word Auto Scaling 사용 설명서의 Auto Scaling 그룹에 대한 조정 활동 확인을 참조하세요. EC2 Auto Scaling
예 2: 삭제된 그룹에 대한 크기 조정 활동을 설명하는 방법
Auto Scaling 그룹이 삭제된 후 크기 조정 활동을 설명하려면
--include-deleted-groups
옵션을 추가하세요.aws autoscaling describe-scaling-activities \ --auto-scaling-group-name
my-asg
\ --include-deleted-groups출력:
{ "Activities": [ { "ActivityId": "e1f5de0e-f93e-1417-34ac-092a76fba220", "Description": "Launching a new EC2 instance. Status Reason: Your Spot request price of 0.001 is lower than the minimum required Spot request fulfillment price of 0.0031. Launching EC2 instance failed.", "AutoScalingGroupName": "my-asg", "Cause": "At 2021-01-13T20:47:24Z a user request update of AutoScalingGroup constraints to min: 1, max: 5, desired: 3 changing the desired capacity from 0 to 3. At 2021-01-13T20:47:27Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 3.", "StartTime": "2021-01-13T20:47:30.094Z", "EndTime": "2021-01-13T20:47:30Z", "StatusCode": "Failed", "StatusMessage": "Your Spot request price of 0.001 is lower than the minimum required Spot request fulfillment price of 0.0031. Launching EC2 instance failed.", "Progress": 100, "Details": "{\"Subnet ID\":\"subnet-5ea0c127\",\"Availability Zone\":\"us-west-2b\"}", "AutoScalingGroupState": "Deleted", "AutoScalingGroupARN": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:283179a2-f3ce-423d-93f6-66bb518232f7:autoScalingGroupName/my-asg" } ] }
자세한 내용은 Amazon EC2 Auto Scaling 사용 설명서의 Amazon Word Auto Scaling 문제 해결을 참조하세요. EC2 Auto Scaling
예 3: 지정된 개수의 크기 조정 활동을 설명하는 방법
특정 개수의 활동을 반환하려면
--max-items
옵션을 사용하세요.aws autoscaling describe-scaling-activities \ --max-items
1
출력:
{ "Activities": [ { "ActivityId": "f9f2d65b-f1f2-43e7-b46d-d86756459699", "Description": "Launching a new EC2 instance: i-0d44425630326060f", "AutoScalingGroupName": "my-asg", "Cause": "At 2020-10-30T19:35:51Z a user request update of AutoScalingGroup constraints to min: 0, max: 16, desired: 16 changing the desired capacity from 0 to 16. At 2020-10-30T19:36:07Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 16.", "StartTime": "2020-10-30T19:36:09.766Z", "EndTime": "2020-10-30T19:36:41Z", "StatusCode": "Successful", "Progress": 100, "Details": "{\"Subnet ID\":\"subnet-5ea0c127\",\"Availability Zone\":\"us-west-2b\"}" } ] }
출력에
NextToken
필드가 포함된 경우 활동이 더 많습니다. 추가 활동을 가져오려면 다음과 같이 후속 직접 호출에서 이 필드의 값을--starting-token
옵션과 함께 사용하세요.aws autoscaling describe-scaling-activities \ --starting-token
Z3M3LMPEXAMPLE
자세한 내용은 Amazon Word Auto Scaling 사용 설명서의 Auto Scaling 그룹에 대한 조정 활동 확인을 참조하세요. EC2 Auto Scaling
-
API 세부 정보는 AWS CLI 명령 참조의 DescribeScalingActivities
를 참조하세요.
-
- Java
-
- Java 2.x용 SDK
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. public static void describeScalingActivities(AutoScalingClient autoScalingClient, String groupName) { try { DescribeScalingActivitiesRequest scalingActivitiesRequest = DescribeScalingActivitiesRequest.builder() .autoScalingGroupName(groupName) .maxRecords(10) .build(); DescribeScalingActivitiesResponse response = autoScalingClient .describeScalingActivities(scalingActivitiesRequest); List<Activity> activities = response.activities(); for (Activity activity : activities) { System.out.println("The activity Id is " + activity.activityId()); System.out.println("The activity details are " + activity.details()); } } catch (AutoScalingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
-
API 세부 정보는 DescribeScalingActivities AWS SDK for Java 2.x 참조의 API를 참조하세요.
-
- Kotlin
-
- Kotlin용 SDK
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. suspend fun describeAutoScalingGroups(groupName: String) { val groupsReques = DescribeAutoScalingGroupsRequest { autoScalingGroupNames = listOf(groupName) maxRecords = 10 } AutoScalingClient { region = "us-east-1" }.use { autoScalingClient -> val response = autoScalingClient.describeAutoScalingGroups(groupsReques) response.autoScalingGroups?.forEach { group -> println("The service to use for the health checks: ${group.healthCheckType}") } } }
-
API 세부 정보는 Word for Kotlin DescribeScalingActivities
참조의 Word를 참조하세요. AWS SDK API
-
- PHP
-
- PHP용 SDK
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. public function describeScalingActivities($autoScalingGroupName) { return $this->autoScalingClient->describeScalingActivities([ 'AutoScalingGroupName' => $autoScalingGroupName, ]); }
-
API 세부 정보는 DescribeScalingActivities AWS SDK for PHP 참조의 API를 참조하세요.
-
- PowerShell
-
- for PowerShell 도구
-
예제 1: 이 예제에서는 지정된 Auto Scaling 그룹의 지난 6주 동안의 조정 활동을 설명합니다.
Get-ASScalingActivity -AutoScalingGroupName my-asg
출력:
ActivityId : 063308ae-aa22-4a9b-94f4-9fae4EXAMPLE AutoScalingGroupName : my-asg Cause : At 2015-11-22T15:45:16Z a user request explicitly set group desired capacity changing the desired capacity from 1 to 2. At 2015-11-22T15:45:34Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 1 to 2. Description : Launching a new EC2 instance: i-26e715fc Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : 11/22/2015 7:46:09 AM Progress : 100 StartTime : 11/22/2015 7:45:35 AM StatusCode : Successful StatusMessage : ActivityId : ce719997-086d-4c73-a2f1-ab703EXAMPLE AutoScalingGroupName : my-asg Cause : At 2015-11-20T22:57:53Z a user request created an AutoScalingGroup changing the desired capacity from 0 to 1. At 2015-11-20T22:57:58Z an instance was started in response to a difference betwe en desired and actual capacity, increasing the capacity from 0 to 1. Description : Launching a new EC2 instance: i-93633f9b Details : {"Availability Zone":"us-west-2b","Subnet ID":"subnet-5264e837"} EndTime : 11/20/2015 2:58:32 PM Progress : 100 StartTime : 11/20/2015 2:57:59 PM StatusCode : Successful StatusMessage :
예제 2: 이 예제에서는 지정된 조정 활동을 설명합니다.
Get-ASScalingActivity -ActivityId "063308ae-aa22-4a9b-94f4-9fae4EXAMPLE"
예제 3: 이 예제에서는 모든 Auto Scaling 그룹의 지난 6주 동안의 조정 활동을 설명합니다.
Get-ASScalingActivity
-
API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조의 DescribeScalingActivities를 참조하세요.
-
- Python
-
- Python용 SDK(Boto3)
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. class AutoScalingWrapper: """Encapsulates Amazon EC2 Auto Scaling actions.""" def __init__(self, autoscaling_client): """ :param autoscaling_client: A Boto3 Amazon EC2 Auto Scaling client. """ self.autoscaling_client = autoscaling_client def describe_scaling_activities(self, group_name: str) -> List[Dict[str, Any]]: """ Gets information about scaling activities for the group. Scaling activities are things like instances stopping or starting in response to user requests or capacity changes. :param group_name: The name of the group to look up. :return: A list of dictionaries representing the scaling activities for the group, ordered with the most recent activity first. :raises ClientError: If there is an error describing the scaling activities. """ try: paginator = self.autoscaling_client.get_paginator( "describe_scaling_activities" ) response_iterator = paginator.paginate(AutoScalingGroupName=group_name) activities = [] for response in response_iterator: activities.extend(response.get("Activities", [])) logger.info( f"Successfully described scaling activities for group '{group_name}'." ) except ClientError as err: error_code = err.response["Error"]["Code"] logger.error( f"Couldn't describe scaling activities for group '{group_name}'. Error code: {error_code}, Message: {err.response['Error']['Message']}" ) if error_code == "ResourceContentionFault": logger.error( f"There is a conflict with another operation that is modifying the Auto Scaling group '{group_name}'. " "Please try again later." ) raise else: return activities
-
API 세부 정보는 Word for Python(Boto3) DescribeScalingActivities 참조의 Word를 참조하세요. AWS SDK API
-
- Rust
-
- Rust용 SDK
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. pub async fn describe_scenario(&self) -> AutoScalingScenarioDescription { let group = self .autoscaling .describe_auto_scaling_groups() .auto_scaling_group_names(self.auto_scaling_group_name.clone()) .send() .await .map(|s| { s.auto_scaling_groups() .iter() .map(|s| { format!( "{}: {}", s.auto_scaling_group_name().unwrap_or("Unknown"), s.status().unwrap_or("Unknown") ) }) .collect::<Vec<String>>() }) .map_err(|e| { ScenarioError::new("Failed to describe auto scaling groups for scenario", &e) }); let instances = self .list_instances() .await .map_err(|e| anyhow!("There was an error listing instances: {e}",)); // 10. DescribeScalingActivities: list the scaling activities that have occurred for the group so far. // Bonus: use CloudWatch API to get and show some metrics collected for the group. // CW.ListMetrics with Namespace='AWS/AutoScaling' and Dimensions=[{'Name': 'AutoScalingGroupName', 'Value': }] // CW.GetMetricStatistics with Statistics='Sum'. Start and End times must be in UTC! let activities = self .autoscaling .describe_scaling_activities() .auto_scaling_group_name(self.auto_scaling_group_name.clone()) .into_paginator() .items() .send() .collect::<Result<Vec<_>, _>>() .await .map_err(|e| { anyhow!( "There was an error retrieving scaling activities: {}", DisplayErrorContext(&e) ) }); AutoScalingScenarioDescription { group, instances, activities, } }
-
API 세부 정보는 Word for Rust DescribeScalingActivities
참조의 Word를 참조하세요. AWS SDK API
-
AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 섹션을 참조하세요a AWS SDK에서이 서비스 사용. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.