LLM metrics monitoring
Function Compute supports metrics monitoring for LLM inference services in GPU functions. You can use the LLM metrics switch (enableLlmMetrics) in the log configuration to view data such as request status, token throughput, and time to first token in the console. When simple monitoring mode is enabled, turn on the enableLlmMetrics switch to display the LLM Metrics tab on the function monitoring page.
Prerequisites
-
You have created a GPU function that uses the vLLM or SGLang inference framework.
-
You have enabled Log Service.
Limitations
-
LLM metrics monitoring is available only for GPU functions.
-
The log configuration mode must be set to custom configuration. You cannot enable LLM metrics in automatic configuration mode.
-
For SGLang, you must explicitly add the
--enable-metricsparameter to the startup command. vLLM enables metrics by default.
Enable LLM metrics
Enable metrics when you create a function
To enable LLM metrics monitoring when you create a function:
-
Log on to the Function Compute console. In the top navigation bar, select a Region.
-
In the left-side navigation pane, choose Function Management > Functions. In the right pane, click Create Function.
-
On the Choose Your Best-Fit Function Type page, select GPU Function and click Create {title}.
-
On the Create {title} page, in the Log Monitoring, Tracing Analysis section under Advanced Settings, set Configuration Mode to Custom Configuration and LLM Metrics to Enable.
-
Configure the other parameters as described in Create a GPU function, and then click Create.
-
Verify: After the function is created, go to the function details page, click the Monitoring tab, and confirm that the LLM Metrics tab appears.
Metrics collection starts only after the instance starts running. If you use SGLang, add --enable-metrics to the startup command.
LLM metrics monitoring is now enabled for the function.
Enable metrics for an existing function
To enable LLM metrics for an existing function:
-
Log on to the Function Compute console and select a region in the top navigation bar.
-
In the left-side navigation pane, choose Function Management > Functions, and then click the name of your function.
-
Click the Configuration tab, find the Advanced Settings section, and click Modify in the upper-right corner to open the advanced configuration page.
-
In the Logs section, set LLM Metrics to on and click Deploy.
-
After instance rotation completes and new instances are created, you can view the LLM metrics on the function monitoring page.
-
Verify: On the function monitoring page, confirm that the LLM Metrics tab appears, and check the log configuration to confirm that the LLM metrics switch is in effect.
Unlike vLLM, which enables metrics by default, SGLang requires the --enable-metrics startup parameter to be explicitly added.
When the LLM metrics tab appears
The LLM Metrics tab appears on the function monitoring page only when all of the following conditions are met:
-
The function is a GPU function.
-
The current region supports the LLM metrics feature.
-
One of the following conditions is met:
-
Simple monitoring mode is not enabled.
-
Simple monitoring mode is enabled, and the LLM metrics switch is turned on in the log configuration.
-
If simple monitoring mode is enabled and you need to view LLM metrics on the function monitoring page, turn on the LLM metrics switch in the log configuration. In this case, the LLM Metrics tab is displayed even in simple mode.
View LLM metrics
-
Log on to the Function Compute console. In the top navigation bar, select a Region.
-
In the left-side navigation pane, choose Function Management > Functions, and then click the name of your function.
-
On the function details page, click the Monitoring tab.
-
Click the LLM Metrics subtab to view the metrics. You can hover over the charts to see detailed values.
If LLM metrics are not enabled, the page displays a message with a link to the log configuration page.
Metrics
vLLM metrics
vLLM supports the following metrics:
|
Metric name |
Description |
|
Requests status |
The status of requests. Valid values: Running, Waiting, and Swapped. |
|
Token throughput (tokens/sec) |
The number of tokens processed per second. |
|
Request completion status |
The completion status of requests. |
|
Time to first token (seconds) |
The time from request start to the first generated token. |
|
End-to-end request latency (seconds) |
The total time to process a request from start to finish. |
|
Queue time (seconds) |
The time a request waits in the queue before processing begins. |
|
Inference time (seconds) |
The time spent on model inference. |
|
Prefill time (seconds) |
The time spent processing the input prompt (the prefill stage). |
|
Decode time (seconds) |
The time spent generating output tokens (the decode stage). |
|
Processed prefill tokens |
The number of processed prefill tokens. |
|
Processed generation tokens |
The number of processed generation tokens. |
|
Request parameters |
The parameters of a request. |
SGLang metrics
SGLang supports the following metrics:
|
Metric name |
Description |
|
Number of requests |
The number of requests. |
|
Token throughput (tokens/sec) |
The number of tokens processed per second. |
|
Time to first token (seconds) |
The time from request start to the first generated token. |
|
End-to-end request latency |
The total time to process a request from start to finish. |
|
KV cache hit rate (%) |
The percentage of lookups served from the KV cache. |
|
Number of used tokens |
The number of used tokens. |
|
Token usage (%) |
The token usage as a percentage. |
Several metrics support percentile statistics:
For example, the vLLM metrics Time to First Token (seconds), E2E Request Latency (seconds), Queue Time (seconds), Inference Time (seconds), Prefill Time (seconds), Decode Time (seconds), Processed Prefill Tokens, and Processed Generation Tokens, and the SGLang metrics Time to First Token (seconds) and E2E Request Latency.