-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: metrics reporting when LLM plugin is not enabled #12841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Fix incorrect metrics reporting when LLM plugin is not enabled. Change default values from '0' to '' for LLM-related nginx variables (llm_time_to_first_token, llm_prompt_tokens, llm_completion_tokens) to properly detect when LLM functionality is not active. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
We found in apisix/plugins/prometheus/exporter.lua#L376-L394 that metrics are reported when the value is not empty. When the LLM plugin is not enabled, the default value is 0, which results in invalid metrics. |
|
Another possible solution is to check if |
Adjust the if statement might help |
|
Hi @qiqizjl, the proposed changes in this PR are incomplete and will cause a regression. We recommend creating an issue first to discuss a solution for this problem. |
Summary
Fix incorrect metrics reporting when LLM plugin is not enabled.
Problem
When the LLM plugin is not enabled, the nginx variables for LLM metrics were defaulting to '0', which caused the metrics to be incorrectly reported as active even when no LLM functionality was being used.
Solution
Changed the default values from '0' to '' (empty string) for the following nginx variables:
llm_time_to_first_tokenllm_prompt_tokensllm_completion_tokensAlso updated the condition check in
openai-base.luato properly detect when LLM functionality is not active.Changes
apisix/cli/ngx_tpl.lua: Changed default values from '0' to ''apisix/plugins/ai-drivers/openai-base.lua: Updated condition check🤖 Generated with Claude Code