prometheus-node-exporter-lua: add newline to error messages

Description:

1. Avoid error on nil value by skipping over it
2. Adds a newline to error messages

Signed-off-by: Amos Shapira <amos.shapira@gmail.com>
[bump version]
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
Amos Shapira
2025-06-04 18:54:11 +10:00
committed by Etienne Champetier
parent 3b2a63dae2
commit bb43d5f28e
2 changed files with 5 additions and 2 deletions

View File

@@ -33,6 +33,9 @@ end
function print_metric(metric, labels, value)
local label_string = ""
if type(value) == "nil" then
return
end
if labels then
for label,value in pairs(labels) do
label_string = label_string .. label .. '="' .. value .. '",'
@@ -59,7 +62,7 @@ function timed_scrape(collector)
local status, err = pcall(collector.scrape)
if not status then
success = 0
io.stderr:write(err)
io.stderr:write(err .. '\n')
end
return (socket.gettime() - start_time), success
end