xuande opened a new issue, #12710:
URL: https://github.com/apache/apisix/issues/12710
### Description
I want to count token usage via APISIX Prometheus metrics, but the metric
`apisix_llm_completion_tokens` does not appear in the metrics information. The
available metric information is as follows
```
# HELP apisix_etcd_modify_indexes Etcd modify index for APISIX keys
# TYPE apisix_etcd_modify_indexes gauge
apisix_etcd_modify_indexes{key="consumers"} 52
apisix_etcd_modify_indexes{key="global_rules"} 0
apisix_etcd_modify_indexes{key="max_modify_index"} 433
apisix_etcd_modify_indexes{key="prev_index"} 432
apisix_etcd_modify_indexes{key="protos"} 0
apisix_etcd_modify_indexes{key="routes"} 433
apisix_etcd_modify_indexes{key="services"} 0
apisix_etcd_modify_indexes{key="ssls"} 0
apisix_etcd_modify_indexes{key="stream_routes"} 0
apisix_etcd_modify_indexes{key="upstreams"} 0
apisix_etcd_modify_indexes{key="x_etcd_index"} 433
# HELP apisix_etcd_reachable Config server etcd reachable from APISIX, 0 is
unreachable
# TYPE apisix_etcd_reachable gauge
apisix_etcd_reachable 1
# HELP apisix_http_requests_total The total number of client requests since
APISIX started
# TYPE apisix_http_requests_total gauge
apisix_http_requests_total 131
# HELP apisix_llm_active_connections Number of active connections to LLM
service
# TYPE apisix_llm_active_connections gauge
apisix_llm_active_connections{route="",route_id="00000000000000000045",matched_uri="/anythings",matched_host="",service="",service_id="",consumer="test",node="ai-proxy-openai-compatible",request_type="ai_stream",request_llm_model="",llm_model="DeepSeek-R1-Distill-Qwen-7B"}
0
# HELP apisix_nginx_http_current_connections Number of HTTP connections
# TYPE apisix_nginx_http_current_connections gauge
apisix_nginx_http_current_connections{state="accepted"} 21
apisix_nginx_http_current_connections{state="active"} 12
apisix_nginx_http_current_connections{state="handled"} 21
apisix_nginx_http_current_connections{state="reading"} 0
apisix_nginx_http_current_connections{state="waiting"} 3
apisix_nginx_http_current_connections{state="writing"} 9
# HELP apisix_nginx_metric_errors_total Number of nginx-lua-prometheus errors
# TYPE apisix_nginx_metric_errors_total counter
apisix_nginx_metric_errors_total 0
# HELP apisix_node_info Info of APISIX node
# TYPE apisix_node_info gauge
apisix_node_info{hostname="01b867fd7d11",version="3.14.1"} 1
# HELP apisix_shared_dict_capacity_bytes The capacity of each nginx shared
DICT since APISIX start
# TYPE apisix_shared_dict_capacity_bytes gauge
apisix_shared_dict_capacity_bytes{name="access-tokens"} 1048576
apisix_shared_dict_capacity_bytes{name="balancer-ewma"} 10485760
apisix_shared_dict_capacity_bytes{name="balancer-ewma-last-touched-at"}
10485760
apisix_shared_dict_capacity_bytes{name="balancer-ewma-locks"} 10485760
apisix_shared_dict_capacity_bytes{name="cas_sessions"} 10485760
apisix_shared_dict_capacity_bytes{name="discovery"} 1048576
apisix_shared_dict_capacity_bytes{name="etcd-cluster-health-check"} 10485760
apisix_shared_dict_capacity_bytes{name="ext-plugin"} 1048576
apisix_shared_dict_capacity_bytes{name="internal-status"} 10485760
apisix_shared_dict_capacity_bytes{name="introspection"} 10485760
apisix_shared_dict_capacity_bytes{name="jwks"} 1048576
apisix_shared_dict_capacity_bytes{name="lrucache-lock"} 10485760
apisix_shared_dict_capacity_bytes{name="mcp-session"} 10485760
apisix_shared_dict_capacity_bytes{name="memory_cache"} 52428800
apisix_shared_dict_capacity_bytes{name="nacos"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-ai-rate-limiting"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-ai-rate-limiting-reset-header"}
10485760
apisix_shared_dict_capacity_bytes{name="plugin-api-breaker"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-limit-conn"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-limit-conn-redis-cluster-slot-lock"}
1048576
apisix_shared_dict_capacity_bytes{name="plugin-limit-count"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-limit-count-redis-cluster-slot-lock"}
1048576
apisix_shared_dict_capacity_bytes{name="plugin-limit-count-reset-header"}
10485760
apisix_shared_dict_capacity_bytes{name="plugin-limit-req"} 10485760
apisix_shared_dict_capacity_bytes{name="plugin-limit-req-redis-cluster-slot-lock"}
1048576
apisix_shared_dict_capacity_bytes{name="prometheus-cache"} 10485760
apisix_shared_dict_capacity_bytes{name="prometheus-metrics"} 10485760
apisix_shared_dict_capacity_bytes{name="upstream-healthcheck"} 10485760
apisix_shared_dict_capacity_bytes{name="worker-events"} 10485760
# HELP apisix_shared_dict_free_space_bytes The free space of each nginx
shared DICT since APISIX start
# TYPE apisix_shared_dict_free_space_bytes gauge
apisix_shared_dict_free_space_bytes{name="access-tokens"} 1032192
apisix_shared_dict_free_space_bytes{name="balancer-ewma"} 10412032
apisix_shared_dict_free_space_bytes{name="balancer-ewma-last-touched-at"}
10412032
apisix_shared_dict_free_space_bytes{name="balancer-ewma-locks"} 10412032
apisix_shared_dict_free_space_bytes{name="cas_sessions"} 10412032
apisix_shared_dict_free_space_bytes{name="discovery"} 1032192
apisix_shared_dict_free_space_bytes{name="etcd-cluster-health-check"}
10412032
apisix_shared_dict_free_space_bytes{name="ext-plugin"} 1032192
apisix_shared_dict_free_space_bytes{name="internal-status"} 10412032
apisix_shared_dict_free_space_bytes{name="introspection"} 10412032
apisix_shared_dict_free_space_bytes{name="jwks"} 1032192
apisix_shared_dict_free_space_bytes{name="lrucache-lock"} 10412032
apisix_shared_dict_free_space_bytes{name="mcp-session"} 10412032
apisix_shared_dict_free_space_bytes{name="memory_cache"} 52113408
apisix_shared_dict_free_space_bytes{name="nacos"} 10412032
apisix_shared_dict_free_space_bytes{name="plugin-ai-rate-limiting"} 10407936
apisix_shared_dict_free_space_bytes{name="plugin-ai-rate-limiting-reset-header"}
10407936
apisix_shared_dict_free_space_bytes{name="plugin-api-breaker"} 10412032
apisix_shared_dict_free_space_bytes{name="plugin-limit-conn"} 10412032
apisix_shared_dict_free_space_bytes{name="plugin-limit-conn-redis-cluster-slot-lock"}
1036288
apisix_shared_dict_free_space_bytes{name="plugin-limit-count"} 10412032
apisix_shared_dict_free_space_bytes{name="plugin-limit-count-redis-cluster-slot-lock"}
1036288
apisix_shared_dict_free_space_bytes{name="plugin-limit-count-reset-header"}
10412032
apisix_shared_dict_free_space_bytes{name="plugin-limit-req"} 10412032
apisix_shared_dict_free_space_bytes{name="plugin-limit-req-redis-cluster-slot-lock"}
1036288
apisix_shared_dict_free_space_bytes{name="prometheus-cache"} 10403840
apisix_shared_dict_free_space_bytes{name="prometheus-metrics"} 10375168
apisix_shared_dict_free_space_bytes{name="upstream-healthcheck"} 10412032
apisix_shared_dict_free_space_bytes{name="worker-events"} 10412032
```
### Environment
- APISIX version (run `apisix version`): 3.14.1
- Operating system (run `uname -a`): Ubuntu22.04
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx
version: openresty/1.27.1.2
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`): 3.5.11
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]