Instance-level metrics

更新时间:
复制 MD 格式

Function Compute provides instance-level metrics, which provide insight into core metrics like vCPU usage, memory usage, network conditions, and concurrency per instance. This topic describes instance-level metrics and explains how to configure them.

Background

Function Compute is an event-driven, fully managed compute service that lets you run code without provisioning or managing servers. However, as you develop and operate your applications, you might have the following questions:

  • For CPU-intensive workloads, how can I see the exact vCPU usage?

  • How do I determine the right concurrency per instance?

  • When a function fails, how do I know if it was caused by a code exception or an instance performance issue?

Function Compute provides instance-level metrics to help you answer these questions and understand the health of each function instance.

Overview

Instance-level metrics are performance indicators for a function instance. They provide real-time monitoring and data collection. This data is then visualized, providing an end-to-end path for monitoring and troubleshooting your function instances.

Instance-level metrics are available for the following dimensions:

  • Function or function qualifier: Metrics are aggregated at the function level. For example, if a function is running on two instances simultaneously, the function-level vCPU metric shows the maximum vCPU usage across both instances.

  • Instance: Metrics for a specific function instance.

Note
  • A qualifier is the version or alias that you specify when you invoke a function. 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, and you cannot directly manage instances.

Metrics

After you enable instance-level metrics, the system collects metrics about function execution. You can view these metrics in the following ways:

  • Monitoring Center: The Monitoring Center in Function Compute includes a built-in dashboard for instance-level metrics. Log on to the Function Compute console and go to the Monitoring Center to view the following information:

    • Metrics of instances aggregated at the function level.

    • Metrics for all instances.

    • Metrics for a specific instance.

  • Log Service: Function Compute sends instance metric data to Log Service (SLS). You can use the analysis capabilities of SLS to create custom dashboards. For more information, see Query and analyze logs.

    Function Compute logs instance-level metrics at regular intervals. A log entry is formatted as follows:

    05-21 11:53:03  FCInstanceMetrics:monitor-center/hello
        aggPeriodSeconds :10
        concurrentRequests :0
        cpuPercent :0.00
        cpuQuotaPercent :8.33
        functionName :hello
        hostname :93b88cee3f03
        instanceID :3512b003-3263-4434-bc75-a4f7a1a181d1
        ipAddress :21.0.3.1
        memoryLimitMB :128.00
        memoryUsageMB :16.87
        memoryUsagePercent :13.18
        operation :CollectInstanceMetrics
        qualifier :LATEST
        rxBytes :0
        rxTotalBytes :158875
        serviceName :monitor-center
        txBytes :0
        txTotalBytes :36123
        versionId :

The following table describes the collected instance-level metrics.

Parameter

Description

Example

cpuPercent

The vCPU utilization, which represents the number of vCPU cores in use. This value can exceed 100%.

120%

cpuQuotaPercent

The maximum expected vCPU quota for the instance. You can configure the vCPU and memory specifications. The vCPU-to-memory ratio (vCPU:GB) must be between 1:1 and 1:4.

50%

memoryUsageMB

The amount of memory used by the instance, in MB.

16.87

memoryLimitMB

The memory limit for the instance, in MB.

1024

rxBytes

The inbound traffic for the instance during the log recording interval, in bytes.

158

txBytes

The outbound traffic from the instance during the log recording interval, in bytes.

1598

rxTotalBytes

The total inbound traffic received by the instance since it started, in bytes.

158875

txTotalBytes

The total outbound traffic sent by the instance since it started, in bytes.

36123

concurrentRequests

The number of concurrent requests on the instance.

10

hostname

The hostname of the function instance.

93b88cee3f03

Note
  • cpuQuotaPercent is a theoretical value, and if the cpuPercent value exceeds the cpuQuotaPercent value, the current function instance preempts resources from other function instances on the same host machine.

  • Communication between function instances and system modules generates a small amount of traffic. Therefore, network traffic is recorded even if your function does not perform any network operations.

  • Instance traffic metrics represent the total network I/O of the instance and do not distinguish between public and private network traffic. You cannot use these metrics to calculate traffic costs.

Configure instance-level metrics

  1. Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.

  2. In the top navigation bar, select a region. On the Services page, find the desired service and click Configure in the Actions column.

  3. On the service modification page, in the Log Settings section, enable Instance-level Metrics and click Save.

    Note

    If logging is not enabled for the service, you must first enable and configure it in the Log Settings section.

Result

After you enable instance-level metrics, you can view metrics such as vCPU usage, memory usage, network conditions, and concurrent requests for your instances on the Monitoring Center page.