feat(prometheus-exporter): add metrics-pole for power metrics
This commit is contained in:
16
prometheus-exporter/utils/prometheus.lua
Normal file
16
prometheus-exporter/utils/prometheus.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
local M = {}
|
||||
|
||||
--- Formats a name + table of labels as a Prometheus metric
|
||||
--- @param name string
|
||||
--- @param labels table
|
||||
--- @param value number
|
||||
function M.counter(name, labels, value)
|
||||
local label_parts = {}
|
||||
for k, v in pairs(labels) do
|
||||
table.insert(label_parts, string.format('%s="%s"', k, v))
|
||||
end
|
||||
local label_str = table.concat(label_parts, ",")
|
||||
return string.format("factorio_%s_total{%s} %d", name, label_str, value)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user