diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua index 93b26c266..1abb7a191 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua @@ -1,8 +1,12 @@ local function scrape() - metric("node_nf_conntrack_entries", "gauge", nil, - string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_count"), 1, -2)) - metric("node_nf_conntrack_entries_limit", "gauge", nil, - string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_max"), 1, -2)) + local count = get_contents("/proc/sys/net/netfilter/nf_conntrack_count") + local max = get_contents("/proc/sys/net/netfilter/nf_conntrack_max") + if count ~= "" then + metric("node_nf_conntrack_entries", "gauge", nil, string.sub(count, 1, -2)) + end + if max ~= "" then + metric("node_nf_conntrack_entries_limit", "gauge", nil, string.sub(max, 1, -2)) + end end return { scrape = scrape }