AlinsRan commented on code in PR #13202:
URL: https://github.com/apache/apisix/pull/13202#discussion_r3385916204


##########
apisix/plugins/prometheus.lua:
##########
@@ -29,18 +29,99 @@ local schema = {
 }
 
 
+-- Per-metric list of built-in labels whose values can be collapsed to an empty
+-- string to reduce cardinality. The `enum` of each metric intentionally omits
+-- structural labels that define the metric's identity (`code` on 
`http_status`,
+-- `type` on `http_latency`/`bandwidth`), so they cannot be disabled. The enum
+-- must stay in sync with `metric_label_map` in exporter.lua.
+local metadata_schema = {
+    type = "object",
+    properties = {
+        disabled_labels = {
+            type = "object",
+            properties = {
+                http_status = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route", "matched_uri", "matched_host", 
"service",
+                                "consumer", "node", "request_type",
+                                "request_llm_model", "llm_model", 
"response_source"},
+                    },
+                },
+                http_latency = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route", "service", "consumer", "node",
+                                "request_type", "request_llm_model", 
"llm_model"},
+                    },
+                },
+                bandwidth = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route", "service", "consumer", "node",
+                                "request_type", "request_llm_model", 
"llm_model"},
+                    },
+                },
+                llm_latency = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route_id", "service_id", "consumer", "node",
+                                "request_type", "request_llm_model", 
"llm_model"},
+                    },
+                },
+                llm_prompt_tokens = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route_id", "service_id", "consumer", "node",
+                                "request_type", "request_llm_model", 
"llm_model"},
+                    },
+                },
+                llm_completion_tokens = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route_id", "service_id", "consumer", "node",
+                                "request_type", "request_llm_model", 
"llm_model"},
+                    },
+                },
+                llm_active_connections = {
+                    type = "array",
+                    items = {
+                        type = "string",
+                        enum = {"route", "route_id", "matched_uri", 
"matched_host",

Review Comment:
   The `enum` lists in `metadata_schema` (`prometheus.lua`) are a manual copy of
   `metric_label_map` (`exporter.lua`) minus the structural labels. They live in
   different files and must be kept in sync by hand — easy to drift.
   
   



-- 
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]

Reply via email to