-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apisix/prometheus): patch to support custom default_buckets (#42)
* fix(apisix/prometheus): patch to support custom default_buckets * feat(prometheus/enable_official): add option enable_official
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/build/patches/001_change_prometheus_default_buckets.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/apisix/plugins/prometheus/exporter.lua b/apisix/plugins/prometheus/exporter.lua | ||
index 45ff94c3..5434ce56 100644 | ||
--- a/apisix/plugins/prometheus/exporter.lua | ||
+++ b/apisix/plugins/prometheus/exporter.lua | ||
@@ -168,10 +168,15 @@ function _M.http_init(prometheus_enabled_in_stream) | ||
{"code", "route", "matched_uri", "matched_host", "service", "consumer", "node", | ||
unpack(extra_labels("http_status"))}) | ||
|
||
+ local buckets = DEFAULT_BUCKETS | ||
+ if attr and attr.default_buckets then | ||
+ buckets = attr.default_buckets | ||
+ end | ||
+ | ||
metrics.latency = prometheus:histogram("http_latency", | ||
"HTTP request latency in milliseconds per service in APISIX", | ||
{"type", "route", "service", "consumer", "node", unpack(extra_labels("http_latency"))}, | ||
- DEFAULT_BUCKETS) | ||
+ buckets) | ||
|
||
metrics.bandwidth = prometheus:counter("bandwidth", | ||
"Total bandwidth in bytes consumed per service in APISIX", | ||
@@ -208,6 +213,11 @@ end | ||
|
||
|
||
function _M.http_log(conf, ctx) | ||
+ local attr = plugin.plugin_attr("prometheus") | ||
+ if attr and not attr.enable_official then | ||
+ return | ||
+ end | ||
+ | ||
local vars = ctx.var | ||
|
||
local route_id = "" |