From 36bb0a8d3ebe12d9425e33e273371770450d3e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Tue, 18 Aug 2020 20:42:05 +0800 Subject: [PATCH] chore: should improve the prometheus metric naming (#2073) By looking at name like `apisix_bandwidth` or `apisix_http_latency`, it is hard to guess their units. Also, it is not so clear for where does the overhead come from for `apisix_http_overhead` at the first glance. --- apisix/plugins/prometheus/exporter.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apisix/plugins/prometheus/exporter.lua b/apisix/plugins/prometheus/exporter.lua index 82ccf456..6547456e 100644 --- a/apisix/plugins/prometheus/exporter.lua +++ b/apisix/plugins/prometheus/exporter.lua @@ -69,6 +69,14 @@ function _M.init() clear_tab(metrics) + -- Newly added metrics should follow the naming best pratices described in + -- https://prometheus.io/docs/practices/naming/#metric-names + -- For example, + -- 1. Add unit as the suffix + -- 2. Add `_total` as the suffix if the metric type is counter + -- 3. Use base unit + -- We keep the old metric names for the compatibility. + -- across all services prometheus = base_prometheus.init("prometheus-metrics", "apisix_") metrics.connections = prometheus:gauge("nginx_http_current_connections", @@ -93,11 +101,12 @@ function _M.init() {"code", "route", "service", "node"}) metrics.latency = prometheus:histogram("http_latency", - "HTTP request latency per service in APISIX", + "HTTP request latency in milliseconds per service in APISIX", {"type", "service", "node"}, DEFAULT_BUCKETS) metrics.overhead = prometheus:histogram("http_overhead", - "HTTP request overhead per service in APISIX", + "HTTP request overhead added by APISIX in milliseconds per service " .. + "in APISIX", {"type", "service", "node"}, DEFAULT_BUCKETS) metrics.bandwidth = prometheus:counter("bandwidth",