From b9d2dbf545bc052309baa074c637d4c41dc09c72 Mon Sep 17 00:00:00 2001 From: Sn0rt Date: Thu, 21 Dec 2023 16:35:13 +0800 Subject: [PATCH] fix: mostly_healthy is considered as healthy (#10639) --- apisix/control/v1.lua | 2 +- apisix/plugins/prometheus/exporter.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apisix/control/v1.lua b/apisix/control/v1.lua index 3143ae5948fc..6838ee4cbe64 100644 --- a/apisix/control/v1.lua +++ b/apisix/control/v1.lua @@ -130,7 +130,7 @@ local HTML_TEMPLATE = [[ {% for _, stat in ipairs(stats) do %} {% for _, node in ipairs(stat.nodes) do %} {% i = i + 1 %} - {% if node.status == "healthy" then %} + {% if node.status == "healthy" or node.status == "mostly_healthy" then %} {% else %} diff --git a/apisix/plugins/prometheus/exporter.lua b/apisix/plugins/prometheus/exporter.lua index f795a27a0d2c..50736241bc28 100644 --- a/apisix/plugins/prometheus/exporter.lua +++ b/apisix/plugins/prometheus/exporter.lua @@ -475,8 +475,10 @@ local function collect(ctx, stream_only) local stats = control.get_health_checkers() for _, stat in ipairs(stats) do for _, node in ipairs(stat.nodes) do - metrics.upstream_status:set((node.status == "healthy") and 1 or 0, - gen_arr(stat.name, node.ip, node.port)) + metrics.upstream_status:set( + (node.status == "healthy" or node.status == "mostly_healthy") and 1 or 0, + gen_arr(stat.name, node.ip, node.port) + ) end end