prometheus-node-exporter-lua: Add "node_textfile_mtime_seconds" metric

…for textfile collector, to make it more consistent with the upstream
Prometheus node-exporter

Signed-off-by: Rob Hoelz <rob@hoelz.ro>
[bump version]
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
(cherry picked from commit 4edae84499)
This commit is contained in:
Rob Hoelz
2022-12-02 09:25:17 -06:00
committed by Etienne Champetier
parent 611b372442
commit 87a831fa8e
2 changed files with 7 additions and 1 deletions

View File

@@ -3,8 +3,14 @@
local fs = require "nixio.fs"
local function scrape()
local mtime_metric = metric("node_textfile_mtime_seconds", "gauge")
for metrics in fs.glob("/var/prometheus/*.prom") do
output(get_contents(metrics), '\n')
local stat = fs.stat(metrics)
if stat then
mtime_metric({ file = metrics }, stat.mtime)
end
end
end