This topic describes the concept, scenarios, and usage notes of Insights, and the function metrics collected by Insights. This topic also describes how to query the logs of Insights.

What is Insights?

Concept

Insights summarizes the execution status of function requests. After you enable Insights, the system collects metrics about each execution of a function, including performance metrics, exception metrics, and tracing metrics. These metrics are delivered to the Logstore that you specified when you configure logging.
  • Performance metrics: memory usage, function execution time, initialization time, and cold starts
  • Exception metrics: failed executions and error details
  • Tracing metrics: tracing details and whether sampling is performed

Insights monitors each invocation of a function to provide information about the execution of the function.

Scenarios

  • View the function execution details, performance metrics, and error information.
  • Create custom monitoring dashboards by using function execution logs.

    You can record service logs in functions and use service and analysis logs to create custom monitoring dashboards. For more information, see Create Grafana dashboards based on request-level metrics.

Usage notes

  • Effective scope

    Insights is a configuration item of a service. After Insights is enabled for a service, Insights applies to all functions in the service. A log entry is recorded for every execution of each of the functions.

  • Prerequisites

    You must configure logging before you can enable Insights. The logs of Insights are stored in the Logstore that you specified. For more information, see Configure Log Service resources and view function execution logs.

  • Pricing

    You are charged for log storage when logs are delivered to Log Service. For information about the pricing of Log Service, see Pricing.

Function metrics

After you enable Insights, the system collects metrics about each execution of a function. These metrics are delivered to the Logstore that you specified when you configure logging. If logging is not configured, you cannot enable Insights.

The following figure shows how Insights records the metrics in your Logstore.Insights

The following table describes the metrics collected by Insights.

Metric Description Example Recorded for each invocation
serviceName The name of the service. my-service Yes
functionName The name of the function. my-function Yes
versionId The ID of the version. 12 Yes
qualifier The alias of the service. prod Yes. Default value: LATEST.
requestId The ID of the request. db72ce53-ccbe-4216-af55-642622e01494 Yes
operation The name of the operation. invocation Yes
memoryMB The maximum memory for the function. 512 Yes
memoryUsageMB The memory used to execute the function. 410 Yes
durationMs The duration for which the function is executed. 20.20 Yes
isColdStart Indicates whether a cold start exists. false Yes. Default value: false.
hasFunctionError Indicates whether a function execution error occurs. false Yes. Default value: false.
errorType The type of the function error. Valid values:
  • FunctionOOMError: The function runs out of memory.
  • FunctionTimeoutError: The execution times out.
  • FunctionUnhandledError: other exceptions that are not captured.
FunctionUnhandledError No. This metric is recorded only when a function execution error occurs. In other words, the value of the hasFunctionError metric is true.
initializationDurationMs The duration for which the initializer function is executed. 99.00 No. This metric is recorded only when a cold start occurs and the initializer function is configured.
traceContext The Tracing Analysis context. 371d3ff242fcee9:371d3ff242fcee9:0:1 No. This metric is recorded only when Tracing Analysis is configured.
isSampled Indicates whether the request is sampled by Tracing Analysis. true No. This metric is recorded only when Tracing Analysis is configured.

Query logs

The topics of log entries for Insights are in the following format: FCInsights:serviceName/functionName.

In Log Service, you can configure the following query condition to obtain all the logs of Insights: __topic__: "FCInsights:test-insights/test". For more information, see Query logs.