Function Compute provides instance-level metrics that allow you to view core metrics such as CPU utilization, memory usage, the network conditions of instances, and the number of requests that an instance concurrently processes. This topic describes the background information, definition, and details of instance-level metrics. This topic also describes how to enable collection of instance-level metrics.

Background information

Function Compute is a fully managed and event-driven computing service. You do not need to maintain compute clusters. However, you may encounter the following issues during development until business code runs as expected:
  • View specific CPU utilization for CPU-intensive services.
  • Set the maximum number of requests that a single instance can concurrently process when you use a single instance to concurrently process multiple requests.
  • Check whether a code exception or a performance exception of the instance used to execute your function causes the failure to execute your function.

The instance-level metrics provided by Function Compute can help you resolve the preceding issues and understand the health status of each instance in Function Compute.

What are instance-level metrics?

Instance-level metrics are performance metrics of instances used to execute functions. The instances are monitored and their performance metrics are collected in real time. The metrics are displayed in a visualized manner to provide you with end-to-end monitoring and troubleshooting paths for the instances.

The instance-level metrics can be displayed in the following dimensions:
  • Function or function qualifier: the function-specific metrics of instances. For example, if Function A is executed by two instances at the same time, the function-specific CPU metric is the maximum CPU utilization of these two instances.
  • Instance: the metrics of a specific instance.
Note
  • The qualifier indicates the version information that is passed in when a function is invoked. It can be a version number or an alias.
  • Instances are dynamically created and reclaimed by Function Compute. Each instance exists only for a short period of time. You cannot manage instances.

Metrics

After you enable collection of instance-level metrics, Function Compute collects metrics for function execution. You can view the instance-level metrics in the following ways:
  • Monitoring Center: The Monitoring Center module in Function Compute provides a built-in dashboard that displays instance-level metrics in a visualized manner. You can log on to the Function Compute console and view the following metrics in the dashboard on the Monitoring Center page:
    • Metrics of instances that execute the same function
    • Metrics of all instances
    • Metrics of a specified instance
  • Log Service: Function Compute imports instance-level metrics into Log Service. You can create a custom visual dashboard by using the analysis capabilities of Log Service and the log collection capabilities of Application Real-Time Monitoring Service (ARMS). For more information, see Query logs and Get started with log monitoring.
    The instance-level metrics of each instance are recorded in logs at intervals in the following format. hanshujisuanshilijibiezhibiao
The following table describes the instance-level metrics.
Metric Description Example
cpuPercent The CPU utilization. It indicates the number of used CPU cores. The value may exceed 100%. 120%
cpuQuotaPercent The estimated maximum CPU utilization. The memory and CPUs used to execute functions have the following relationship:
  • On-demand mode: 3 GB of memory corresponds to two vCPUs.
  • Provisioned mode: 2 GB of memory corresponds to one vCPU.
50%
memoryUsageMB The amount of memory used by the instance. Unit: MB. 16.87
memoryLimitMB The maximum amount of memory that can be used by the instance. Unit: MB. 1024
rxBytes The traffic received by the instance in the time interval at which logs are generated. Unit: byte. 158
txBytes The traffic sent by the instance in the time interval at which logs are generated. Unit: byte. 1598
rxTotalBytes The traffic received by the instance since the instance was started. Unit: byte. 158875
txTotalBytes The traffic sent by the instance since the instance was started. Unit: byte. 36123
concurrentRequests The number of requests that the instance concurrently processes. 10
hostname The name of the host on which the instance runs. 36123
Note
  • The cpuQuotaPercent metric is theoretical. The value of the cpuPercent metric may exceed that of the cpuQuotaPercent metric. In this case, the instance preempts the resources of other instances on the same host.
  • The communication between instances and system modules causes a small amount of traffic. Therefore, a small amount of sending and receiving traffic is generated when no network access exists within a function.
  • The traffic of an instance represents only the inbound and outbound traffic of the instance. The Internet traffic and the private network traffic are counted together, and you cannot calculate the traffic fee based on this monitoring chart.

Enable collection of instance-level metrics

Enable collection of instance-level metrics when you create a service

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Services and Functions. Click Create Service in the upper-right corner of the Services pane.
    creat_service
  4. On the Create Service page, enter a service name and select Bind Log.
    Note After you select Bind Log, collection of instance-level metrics is enabled for all functions in the service by default.
    image3hanshujisuanshilijibiezhibiao

Enable collection of instance-level metrics after a service is created

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Services and Functions. In the Services pane, click the service that you require.
  4. On the Services and Functions page, click the service that you require. Then, click the Service Configurations tab. On the Service Configurations tab, click Modify Configuration.
    Modify service configurations
  5. In the Log Config section on the Configure Service page, turn on EnableInstanceMetrics and click Submit.
    hanshujsiuanshilijibiezhibiao2

Result

After collection of instance-level metrics is enabled, you can view the instance-level metrics on the Monitoring Center page.