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

Commit

Permalink
export config_hash as a number
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed May 17, 2021
1 parent 4f8e1ce commit 5ccbc03
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kong/plugins/prometheus/exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ local function init()

metrics.dataplane_last_seen = prometheus:gauge("dataplane_last_seen",
"Last time data plane contacted control plane",
{"node_id", "hostname", "ip", "hash"})
{"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
end
Expand Down Expand Up @@ -357,10 +360,16 @@ local function metric_data()
if cp_metrics then
-- Cleanup old metrics
metrics.dataplane_last_seen:reset()
metrics.dataplane_config_hash:reset()

local data_planes = clustering.get_status()
for node_id, status in pairs(data_planes) do
metrics.dataplane_last_seen:set(status.last_seen, { node_id, status.hostname, status.ip, status.config_hash })
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
metrics.dataplane_config_hash:set(tonumber("0x" .. status.config_hash), labels)
end
end

Expand Down

0 comments on commit 5ccbc03

Please sign in to comment.