This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 36bb0a8  chore: should improve the prometheus metric naming (#2073)
36bb0a8 is described below

commit 36bb0a8d3ebe12d9425e33e273371770450d3e60
Author: 罗泽轩 <spacewander...@gmail.com>
AuthorDate: Tue Aug 18 20:42:05 2020 +0800

    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 82ccf45..6547456 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",

Reply via email to