Function Compute provides instance-level metrics that allow you to view core metrics such as vCPU usage, memory usage, the network conditions of instances, and the number of requests that an instance executes. 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 code development and running:
How to view the vCPU usage in CPU-intensive scenarios.
How to identify the cause of a function execution failure. Possible causes include code exceptions and instance performance exceptions.
The instance-level metrics provided by Function Compute can help you resolve the preceding issues and track the health status of instances 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 vCPU metric is the maximum vCPU utilization of these two instances.
Instance: the metrics of a specific instance.
The qualifier indicates the version information that is passed in when a function is invoked. The value can be either 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 perform operations on instances.
Metrics
After you enable collection of instance-level metrics, Function Compute collects function execution metrics. 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. On the details page of a function, you can click the Monitoring tab to view the dashboard.
Metrics of instances that execute the same function
Metrics of an instance
Simple Log Service: Function Compute imports instance-level metrics into Simple Log Service. You can create a custom visualized dashboard by using the analytics capabilities of Simple Log Service. For more information, see Query and analyze logs.
The instance-level metrics of each instance are recorded in logs at specific intervals. The following figure shows the format.
The following table describes the instance-level metrics.
Metric | Description | Example Value |
cpuPercent | vCPU usage. The value indicates the number of used vCPUs and may exceed 100%. | 120% |
cpuQuotaPercent | The maximum vCPU quota of the instance. You can flexibly configure the vCPU and memory specifications. The vCPU-to-memory ratio (vCPU:GB) must be from 1:1 to 1:4. | 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 volume of data received by the instance in the time interval at which logs are generated. Unit: bytes. | 158 |
txBytes | The volume of data sent by the instance in the time interval at which logs are generated. Unit: bytes. | 1598 |
rxTotalBytes | The volume of data received by the instance since the instance was started. Unit: bytes. | 158875 |
txTotalBytes | The volume of data sent by the instance since the instance was started. Unit: bytes. | 36123 |
concurrentRequests | The number of requests that the instance currently processes. | 10 |
hostname | The name of the host on which the instance runs. | 36123 |
The value of 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 generates a small amount of traffic. Therefore, a small amount of sending and receiving traffic is generated even when no network access is performed 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
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the function that you want to manage.
On the function configuration page, click the Configurations tab.
On the Logs tab, click Edit. In the log panel, enable Instance-level Metrics and click OK.
NoteIf you did not enable the logging feature when you created the service, you must enable the logging feature in the log panel and configure related parameters.
Execution result
After you enable instance-level metrics, you can view the instance-level metrics on the Monitoring tab, such as vCPU usage, memory usage, instance network status, and number of requests of the instance.