Skip to content

AWS EC2

Use the script package series of "Guance Cloud Sync" in the script market to synchronize cloud monitoring and cloud asset data to Guance

Configuration

Install Func

It is recommended to enable Guance Integration - Extension - Hosted Func: all prerequisites are automatically installed. Please proceed with the script installation.

If you deploy Func yourself, refer to Self-deploy Func

Enable Script

Note: Please prepare an Alibaba Cloud AK that meets the requirements in advance (for simplicity, you can directly grant global read-only permission ReadOnlyAccess)

Hosted Version Script Activation

  1. Log in to Guance Console
  2. Click on the 【Integration】 menu, select 【Cloud Account Management】
  3. Click 【Add Cloud Account】, choose 【AWS】, fill in the required information on the interface; if cloud account information has been configured before, skip this step
  4. Click 【Test】, after the test is successful, click 【Save】. If the test fails, check whether the related configuration information is correct and retest.
  5. In the 【Cloud Account Management】 list, you can see the added cloud accounts. Click on the corresponding cloud account to enter the details page.
  6. Click the 【Integration】 button on the cloud account details page. Under the Not Installed list, find AWS EC2, click the 【Install】 button, and install it from the pop-up installation interface.

Manual Script Activation

  1. Log in to the Func console, click 【Script Market】, enter the official script market, and search for guance_aws_ec2
  2. After clicking 【Install】, input the corresponding parameters: AWS AK ID, AK Secret, and account name.
  3. Click 【Deploy Startup Script】, the system will automatically create a Startup script set and configure the corresponding startup script automatically.
  4. After enabling, you can see the corresponding automatic trigger configuration under 「Management / Automatic Trigger Configuration」. Click 【Execute】 to run immediately without waiting for the scheduled time. After a while, you can view the execution task records and corresponding logs.

Verification

  1. In 「Management / Automatic Trigger Configuration」, confirm whether there is an automatic trigger configuration corresponding to the task. You can also check the task records and logs for any abnormalities.
  2. In Guance, 「Infrastructure / Custom」, check if there is any asset information.
  3. In Guance, 「Metrics」, check if there are corresponding monitoring data.

Metrics

After configuring Amazon-CloudWatch, the default measurement sets are as follows. You can collect more metrics through configuration Amazon CloudWatch Metrics Details

Note: If you find that memory or disk metrics are not reported, go to the aws console and manually enable collection.

Instance Metrics

The AWS/EC2 namespace includes the following instance metrics.

Metric Description
CPUUtilization The percentage of physical CPU time used by Amazon EC2 to run EC2 instances, including time spent running user code and Amazon EC2 code. At a high level, CPUUtilization is the sum of guest CPUUtilization and hypervisor CPUUtilization. Due to legacy device emulation, non-legacy configurations, interrupt-heavy workloads, live migrations, and live updates, the percentage displayed by tools in the operating system may differ from CloudWatch. Units: Percentage
DiskReadOps The number of read operations completed from all instance store volumes available to the instance during the specified time period. To calculate the average I/O operations per second (IOPS) for the period, divide the total number of operations for the period by the total number of seconds. If there are no instance store volumes, the value is 0 or the metric is not reported. Units: Count
DiskWriteOps The number of write operations completed to all instance store volumes available to the instance during the specified time period. To calculate the average I/O operations per second (IOPS) for the period, divide the total number of operations for the period by the total number of seconds. If there are no instance store volumes, the value is 0 or the metric is not reported. Units: Count
DiskReadBytes The number of bytes read from all instance store volumes available to the instance. This metric determines the amount of data the application reads from the instance's hard drive. It can be used to determine the speed of the application. The reported quantity is the number of bytes received during the period. If you use basic (5-minute) monitoring, you can divide this number by 300 to get bytes/second. If you use detailed (1-minute) monitoring, divide it by 60. You can also use the CloudWatch metric math function DIFF_TIME to find the number of bytes per second. For example, if you plot DiskReadBytes as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in bytes/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. If there are no instance store volumes, the value is 0 or the metric is not reported. Units: Bytes
DiskWriteBytes The number of bytes written to all instance store volumes available to the instance. This metric determines the amount of data the application writes to the instance's hard drive. It can be used to determine the speed of the application. The reported quantity is the number of bytes received during the period. If you use basic (5-minute) monitoring, you can divide this number by 300 to get bytes/second. If you use detailed (1-minute) monitoring, divide it by 60. You can also use the CloudWatch metric math function DIFF_TIME to find the number of bytes per second. For example, if you plot DiskWriteBytes as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in bytes/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. If there are no instance store volumes, the value is 0 or the metric is not reported. Units: Bytes
MetadataNoToken The number of times the instance metadata service was successfully accessed without a token. This metric determines if any processes are using Instance Metadata Service version 1 to access instance metadata without a token. If all requests use token-supported sessions (i.e., Instance Metadata Service version 2), the value is 0. For more information, see Transitioning to Using Instance Metadata Service Version 2. Units: Count
NetworkIn The number of bytes received by the instance on all network interfaces. This metric determines the incoming network traffic to a single instance. The reported quantity is the number of bytes received during the period. If you use basic (5-minute) monitoring and the statistic is Sum, you can divide this number by 300 to get bytes/second. If you use detailed (1-minute) monitoring and the statistic is Sum, divide it by 60. You can also use the CloudWatch metric math function DIFF_TIME to find the number of bytes per second. For example, if you plot NetworkIn as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in bytes/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. Units: Bytes
NetworkOut The number of bytes sent by the instance on all network interfaces. This metric determines the outgoing network traffic from a single instance. The reported number is the number of bytes sent during the period. If you use basic (5-minute) monitoring and the statistic is Sum, you can divide this number by 300 to get bytes/second. If you use detailed (1-minute) monitoring and the statistic is Sum, divide it by 60. You can also use the CloudWatch metric math function DIFF_TIME to find the number of bytes per second. For example, if you plot NetworkOut as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in bytes/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. Units: Bytes
NetworkPacketsIn The number of packets received by the instance on all network interfaces. This metric identifies the amount of incoming traffic based on the number of packets on a single instance. This metric is only available for basic monitoring (5-minute period). To calculate the number of packets per second (PPS) received by the instance over 5 minutes, divide the Sum statistic by 300. You can also use the CloudWatch metric math function DIFF_TIME to find the number of packets per second. For example, if you plot NetworkPacketsIn as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in packets/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. Units: Count
NetworkPacketsOut The number of packets sent by the instance on all network interfaces. This metric identifies the amount of outgoing traffic based on the number of packets on a single instance. This metric is only available for basic monitoring (5-minute period). To calculate the number of packets per second (PPS) sent by the instance over 5 minutes, divide the Sum statistic by 300. You can also use the CloudWatch metric math function DIFF_TIME to find the number of packets per second. For example, if you plot NetworkPacketsOut as m1 in CloudWatch, the metric math formula m1/(DIFF_TIME(m1)) returns the metric in packets/second. For more information about DIFF_TIME and other metric math functions, see Using Metric Math in the Amazon CloudWatch User Guide. Units: Count

CPU Metrics

The AWS/EC2 namespace includes the following CPU credit metrics for burstable performance instances.

Metric Description
CPUCreditUsage The number of CPU credits spent by the instance to maintain CPU utilization. One CPU credit equals one vCPU running at 100% utilization for one minute, or equivalent combinations of vCPU, utilization, and time (for example, one vCPU running at 50% utilization for two minutes, or two vCPUs running at 25% utilization for two minutes). CPU credit metrics are only provided every five minutes. If you specify a time period greater than five minutes, use the Sum statistic rather than the Average statistic. Units: Credits (vCPU minutes)
CPUCreditBalance The number of CPU credits accumulated since the instance started. For T2 Standard, CPUCreditBalance also includes accumulated launch credits. After credits are earned, they accumulate in the credit balance; after credits are spent, they are deducted from the credit balance. The credit balance has a maximum limit determined by the instance size. Any new credits earned after reaching the limit are discarded. For T2 Standard, launch credits do not count towards the limit. The instance can spend credits in the CPUCreditBalance to burst above the baseline CPU utilization. During the instance's runtime, credits in the CPUCreditBalance do not expire. When a T3 or T3a instance stops, the CPUCreditBalance value is retained for seven days. After that, all accumulated credits are lost. When a T2 instance stops, the CPUCreditBalance value is not retained, and all accumulated credits are lost. CPU credit metrics are only provided every five minutes. Units: Credits (vCPU minutes)
CPUSurplusCreditBalance The number of surplus credits spent by the CPUCreditBalance instance when the unlimited value is zero. The CPUSurplusCreditBalance value is paid for by earned CPU credits. If the surplus credits exceed the maximum number of credits the instance can earn in a 24-hour period, additional charges will be incurred for the surplus credits exceeding the maximum. CPU credit metrics are only provided every five minutes. Units: Credits (vCPU minutes)
CPUSurplusCreditsCharged The number of surplus credits spent that were not paid for by earned CPU credits and incur additional charges. Charges are applied for spent surplus credits in either of the following cases: The spent surplus credits exceed the maximum number of credits the instance can earn in a 24-hour period. For surplus credits exceeding the maximum, you are charged at the end of the hour. The instance has stopped or terminated. The instance switches from unlimited to standard. CPU credit metrics are only provided every five minutes. Units: Credits (vCPU minutes)

Status Check Metrics

The AWS/EC2 namespace includes the following status check metrics. By default, status check metrics are available free of charge at a frequency of 1 minute. For newly launched instances, status check metric data is only available after the instance completes initialization (within a few minutes of entering the running state). For more information about EC2 status checks, see Instance Status Checks. | Metric | Description | | :----------------------------- | :----------------------------------------------------------- | | StatusCheckFailed| Reports whether the instance passed both the instance status check and the system status check in the last minute. This metric can be 0 (passed) or 1 (failed). By default, this metric is available free of charge at a frequency of 1 minute. Units: Count| | StatusCheckFailed_Instance| Reports whether the instance passed the instance status check in the last minute. This metric can be 0 (passed) or 1 (failed). By default, this metric is available free of charge at a frequency of 1 minute. Units: Count| | StatusCheckFailed_System| Reports whether the instance passed the system status check in the last minute. This metric can be 0 (passed) or 1 (failed). By default, this metric is available free of charge at a frequency of 1 minute. Units: Count|

Objects

The collected AWS EC2 object data structure can be viewed in 「Infrastructure - Custom」

{
  "measurement": "aws_ec2",
  "tags": {
    "name"           : "i-0d7620xxxxxxx",
    "InstanceId"     : "i-0d7620xxxxxxx",
    "InstanceType"   : "c6g.xlarge",
    "PlatformDetails": "Linux/UNIX",
    "RegionId"       : "cn-northwest-1",
    "InstanceName"   : "test",
    "State"          : "running",
    "StateReason_Code"   : "Client.UserInitiatedHibernate",
    "AvailabilityZone": "cn-northwest-1",
  },
  "fields": {
    "BlockDeviceMappings": "{Device JSON Data}",
    "LaunchTime"         : "2021-10-26T07:00:44Z",
    "NetworkInterfaces"  : "{Network JSON Data}",
    "Placement"          : "{Availability Zone JSON Data}",
    "message"            : "{Instance JSON Data}"
  }
}

Note: Fields in tags and fields may change with subsequent updates.

Tip 1: The value of tags.name is the instance ID, used for unique identification. Tip 2: fields.message, fields.NetworkInterfaces, fields.BlockDeviceMappings are JSON serialized strings.

Feedback

Is this page helpful? ×