Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
fix(exporter) fix API for balancer in post Kong 2.5 (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion authored Jul 27, 2021
1 parent fbbc19d commit 70ef33f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kong/plugins/prometheus/exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ local lower = string.lower
local concat = table.concat
local select = select
local balancer = require("kong.runloop.balancer")
local get_all_upstreams = balancer.get_all_upstreams
if not balancer.get_all_upstreams then -- API changed since after Kong 2.5
get_all_upstreams = require("kong.runloop.balancer.upstreams").get_all_upstreams
end

local CLUSTERING_SYNC_STATUS = require("kong.constants").CLUSTERING_SYNC_STATUS

Expand Down Expand Up @@ -318,7 +322,7 @@ local function metric_data()
metrics.upstream_target_health:reset()

-- upstream targets accessible?
local upstreams_dict = balancer.get_all_upstreams()
local upstreams_dict = get_all_upstreams()
for key, upstream_id in pairs(upstreams_dict) do
local _, upstream_name = key:match("^([^:]*):(.-)$")
upstream_name = upstream_name and upstream_name or key
Expand Down

0 comments on commit 70ef33f

Please sign in to comment.