summaryrefslogtreecommitdiffstats
path: root/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/textfile.lua
blob: 81a1f6412b24e0253c9aee5cdef5ecdf095a8f3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
    out:write(get_contents(metrics))
    out:write('\n')
    local stat = fs.stat(metrics)
    if stat then
      mtime_metric({ file = metrics }, stat.mtime)
    end
  end
end

return { scrape = scrape }