Tüm Ürünler
Search
Belge Merkezi

Function Compute:İzleme verileri

Son Güncelleme:Oct 08, 2026

Bu konuda, CloudMonitor API kullanılarak Function Compute ölçümlerinin nasıl sorgulanacağı açıklanmaktadır. İlgili API işlemlerini çağırabilir ve farklı istek parametrelerini kullanarak Function Compute izleme verilerini elde edebilirsiniz. Bu parametreler arasında Project, StartTime, EndTime, Dimensions, Period ve Metric bulunur.

API işlemleri hakkında daha fazla bilgi için bkz. API genel bakış.

Project

Tüm Function Compute ölçümleri acs_fc projesi altında sorgulanabilir.

Aşağıdaki örnek kod, SDK for Java kullanılarak projenin nasıl yapılandırılacağını gösterir:

QueryMetricRequest request = new QueryMetricRequest();
request.setProject("acs_fc");

StartTime ve EndTime

CloudMonitor'da bir zaman aralığı, (StartTime, EndTime] biçimindeki StartTime ve EndTime parametreleri ile tanımlanır. Zaman aralığı StartTime'u hariç tutar, EndTime'u dahil eder.

Not

CloudMonitor verileri 31 gün boyunca saklar. Bu nedenle, StartTime ile EndTime arasındaki zaman aralığı 31 günü aşamaz ve 31 günden eski veriler sorgulanamaz.

Diğer zaman parametreleri hakkında daha fazla bilgi için bkz. API genel bakış.

Aşağıdaki örnek kod, SDK for Java kullanılarak projenin nasıl yapılandırılacağını gösterir:

request.setStartTime("2024-07-19 08:00:00");
request.setEndTime("2024-07-19 09:00:00");        

Dimensions

Function Compute izleme hizmeti, Function Compute ölçümlerini bölge, hizmet ve işlev boyutlarına göre ayırır. Her boyut, Dimensions parametresi değeri için farklı bir biçim kullanır.

  • Bölgesel ölçümler için Dimensions parametresi aşağıdaki biçimdedir:

    {"region": "${your_region}"}    
  • İşlev ölçümleri için Dimensions parametresi aşağıdaki biçimdedir:

    {"region": "${your_region}", "functionName": "${your_functionName}"}
Not

Dimensions parametresinin değeri, bir veya daha fazla anahtar-değer çifti içeren bir JSON dizesidir. Aşağıdaki örnek kod, SDK for Java kullanılarak projenin nasıl yapılandırılacağını gösterir:

request.setDimensions("{\"region\":\"your_region\"}");

Period

Function Compute ölçümleri için toplama dönemi granülerliği 60 saniye olmalıdır.

Aşağıdaki örnek kod, SDK for Java kullanılarak projenin nasıl yapılandırılacağını gösterir:

request.setPeriod("60");

Metric

Aşağıdaki örnek kod, SDK for Java kullanılarak projenin nasıl yapılandırılacağını gösterir:

request.setMetric("your_metric");

Aşağıdaki tabloda Function Compute belgelerinde açıklanan ölçümler listelenmiştir.

Boyut

Metric

Bölge kimliği.

RegionTotalInvocations

RegionServerErrors

RegionClientErrors

RegionFunctionErrors

RegionThrottles

RegionResourceThrottles

RegionConcurrencyLimit

RegionConcurrentCount

RegionProvisionedCurrentInstance

İşlev

FunctionTotalInvocations

FunctionProvisionInvocations

FunctionHTTPStatus2xx

FunctionHTTPStatus3xx

FunctionHTTPStatus4xx

FunctionHTTPStatus5xx

FunctionServerErrors

FunctionClientErrors

FunctionFunctionErrors

FunctionConcurrencyThrottles

FunctionResourceThrottles

FunctionAvgDuration

FunctionP90Duration

FunctionP99Duration

FunctionMaxDuration

FunctionLatencyAvg

FunctionMemoryLimitMB

FunctionMaxMemoryUsage

FunctionOndemandInstanceQuota

FunctionOndemandActiveInstance

FunctionProvisionedCurrentInstance

FunctionEnqueueCount

FunctionDequeueCount

FunctionAsyncMessageLatencyAvg

FunctionAsyncMessageLatencyMax

FunctionAsyncEventExpiredDropped

FunctionDestinationErrors

FunctionDestinationSucceed

FunctionAsyncMessagesBacklog

FunctionAsyncMessagesInProcess

FunctionMaxConcurrentRequests

FunctionAvgConcurrentRequests

FunctionvCPUQuotaCores

FunctionMaxvCPUCores

FunctionAvgvCPUCores

FunctionMaxvCPUUtilization

FunctionAvgvCPUUtilization

FunctionRXBytesPerSec

FunctionTXBytesPerSec

FunctionMemoryLimitMB

FunctionMaxMemoryUsageMB

FunctionAvgMemoryUsageMB

FunctionMaxMemoryUtilization

FunctionAvgMemoryUtilization

FunctionGPUMemoryLimitMB

FunctionGPUMaxMemoryUsage

FunctionGPUMemoryUsagePercent

FunctionGPUSMPercent

FunctionGPUEncoderPercent

FunctionGPUDecoderPercent

Örnek:

Aşağıdaki metin, örnek bir pom.xml dosyasını gösterir:

...
    <dependencies>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-cms</artifactId>
            <version>5.0.1</version>
        </dependency>
    </dependencies>
...
            

Örnek kod:

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.cms.model.v20170301.QueryMetricListRequest;
import com.aliyuncs.cms.model.v20170301.QueryMetricListResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;

public class MonitorService {
    public static void main(String[] args) {
        /*
        The AccessKey pair of an Alibaba Cloud account can be used to access all API operations. Using these credentials to perform operations in Function Compute is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. 
        We recommend that you do not save AccesKey pairs (AccessKey IDs and AccessKey secrets) in your project code. Otherwise, the AccessKey pairs may be leaked and the security of all resources in your account may be compromised. 
        In this example, the AccessKey pair is saved to the environment variables for authentication. 
        Configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables in your local environment before you run sample code. 
        In runtimes of Function Compute, the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are automatically configured after you configure the execution permissions. 
        */
        String accessKey = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessSecretKey = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecretKey);
        IAcsClient client = new DefaultAcsClient(profile);

        QueryMetricListRequest request = new QueryMetricListRequest();
        request.setProject("acs_fc");
        request.setPeriod("60");
        request.setStartTime("2023-08-26 16:20:00");
        request.setEndTime("2023-08-26 16:30:00");
        request.setAcceptFormat(FormatType.JSON);

        try {
            // Region dimension. JSONObject dim = new JSONObject();
            request.setMetric("RegionTotalInvocations");  // Specify the metric. 
            dim.put("region", "<your_region>");  //Example: cn-shanghai
            request.setDimensions(dim.toJSONString());
            QueryMetricListResponse response = client.getAcsResponse(request);
            System.out.println(response.getCode());
            System.out.println(response.getMessage());
            System.out.println(response.getRequestId());
            System.out.println(response.getDatapoints());

            // Function dimension. dim = new JSONObject();
            request.setMetric("FunctionTotalInvocations");  // Specify the metric. 
            dim.put("region", "<your_region>");
            dim.put("serviceName", ""); //The name of a function created in Function Compute 2.0: {serviceName}${functionName}. To obtain metrics, you need to use dim.put("serviceName",{serviceName}). A function created in Function Compute 3.0: {functionName}. To obtain metrics, you need to use dim.put("serviceName",""). 
            dim.put("functionName", "<your_function_name>");
            request.setDimensions(dim.toJSONString());
            response = client.getAcsResponse(request);
            System.out.println(response.getCode());
            System.out.println(response.getMessage());
            System.out.println(response.getRequestId());
            System.out.println(response.getDatapoints());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}