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

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed May 17, 2021
1 parent 5ccbc03 commit 82fabac
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions kong/plugins/prometheus/exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,17 @@ local function init()
end

-- Hybrid mode status
if kong.version_num >= 2000000 then -- 200.00.00 -> 2.0.0 then
if kong.configuration.role == "control_plane" then
cp_metrics = true

clustering = require("kong.clustering")

metrics.dataplane_last_seen = prometheus:gauge("dataplane_last_seen",
"Last time data plane contacted control plane",
{"node_id", "hostname", "ip"})
metrics.dataplane_config_hash = prometheus:gauge("dataplane_config_hash",
"Config hash numeric value of the data plane",
{"node_id", "hostname", "ip"})
end
if kong.configuration.role == "control_plane" then
cp_metrics = true

clustering = require("kong.clustering")

metrics.dataplane_last_seen = prometheus:gauge("dataplane_last_seen",
"Last time data plane contacted control plane",
{"node_id", "hostname", "ip"})
metrics.dataplane_config_hash = prometheus:gauge("dataplane_config_hash",
"Config hash numeric value of the data plane",
{"node_id", "hostname", "ip"})
end
end

Expand Down Expand Up @@ -367,8 +365,7 @@ local function metric_data()
local labels = { node_id, status.hostname, status.ip }
metrics.dataplane_last_seen:set(status.last_seen, labels)
-- Note the following will be represented as a float instead of int64 since luajit
-- don't like int64.
-- But prometheus uses float instead of int64 as well
-- don't like int64. Good news is prometheus uses float instead of int64 as well
metrics.dataplane_config_hash:set(tonumber("0x" .. status.config_hash), labels)
end
end
Expand Down

0 comments on commit 82fabac

Please sign in to comment.