The Insights feature summarizes the execution status of function requests. After Insights is enabled, the system collects metrics about every execution of a function, including performance metrics such as memory usage, function execution time, initialization time, and cold starts, exception metrics such as failed executions and error details, and tracing metrics such as tracing details and whether sampling is made. These metrics are delivered to the Logstore that you specified when you configure logging. Insights monitors every invocation of a function to provide information on how the function is executed. This topic describes the core features, scenarios, and usage notes of Insights.
Insights collects metrics about every execution of a function and delivers these metrics to the Logstore that you specified when you configure logging. If logging is not configured, you cannot enable the Insights feature.
The following table describes the metrics collected by Insights.
Metric Description Example Recorded for every invocation serviceName The name of the service. my-service Yes functionName The name of the function. my-function Yes versionId The version ID. 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 available for the function. 512 Yes memoryUsageMB The memory used to execute the function. 410 Yes durationMs The period in 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. Three error types are available:
- 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 (hasFunctionError:true). initializationDurationMs The period in 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.The following figure shows how the metrics are recorded in your Logstore.
- Log topics
The topics of log entries for Insights use the following format:
In Log Service, you can configure the following query condition to obtain all the logs of Insights:
- View the function execution details, performance metrics, and error information.
- Create custom monitoring dashboards by using function logs.
You can record service logs in functions and use service and analysis logs to create custom monitoring dashboards.
- Insights applies to all functions of the service for which Insights is enabled.
Insights is a configuration item of a service. After Insights is enabled for a service, it applies to all functions of the service. A log entry is recorded for every execution of each of the functions.
- You must configure function logs before you can enable Insights.
The logs of Insights are stored in the Logstore that you have configured. For information about how to configure Logstore, see Configure and view function logs.
You are charged for log storage when logs are delivered to Log Service. For information about the pricing of Log Service, see Log Service Pricing.