mirror of
https://github.com/openwrt/packages.git
synced 2025-12-10 12:41:22 +00:00
prometheus-node-exporter-lua: remove zero values
depending on the configuration there may be multiple interfaces creating multiple time series always reporting 0 value. omiting them from the export saves resources. most notably cpu. this is limited to counter types Signed-off-by: Markus Hube <markus.hube@t-online.de>
This commit is contained in:
committed by
Tianling Shen
parent
ba55134a1a
commit
803a754525
@@ -4,7 +4,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=prometheus-node-exporter-lua
|
PKG_NAME:=prometheus-node-exporter-lua
|
||||||
PKG_VERSION:=2025.07.15
|
PKG_VERSION:=2025.11.22
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
|
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ _log() {
|
|||||||
start_service() {
|
start_service() {
|
||||||
. /lib/functions/network.sh
|
. /lib/functions/network.sh
|
||||||
|
|
||||||
local interface port listenflag cert key bind4 bind6
|
local interface port listenflag cert key bind4 bind6 omit_zero_values
|
||||||
|
|
||||||
config_load prometheus-node-exporter-lua.main
|
config_load prometheus-node-exporter-lua.main
|
||||||
config_get keepalive "main" http_keepalive 70
|
config_get keepalive "main" http_keepalive 70
|
||||||
@@ -19,6 +19,7 @@ start_service() {
|
|||||||
config_get port "main" listen_port 9100
|
config_get port "main" listen_port 9100
|
||||||
config_get cert "main" cert
|
config_get cert "main" cert
|
||||||
config_get key "main" key
|
config_get key "main" key
|
||||||
|
config_get omit_zero_values "main" omit_zero_values 0
|
||||||
|
|
||||||
[ "$interface" = "*" ] || {
|
[ "$interface" = "*" ] || {
|
||||||
network_get_ipaddr bind4 "$interface"
|
network_get_ipaddr bind4 "$interface"
|
||||||
@@ -31,6 +32,8 @@ start_service() {
|
|||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
|
|
||||||
|
[ "$omit_zero_values" -eq 1 ] && procd_set_param env OMIT_ZERO_VALUES=1
|
||||||
|
|
||||||
procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua
|
procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua
|
||||||
[ $keepalive -gt 0 ] && procd_append_param command -k $keepalive
|
[ $keepalive -gt 0 ] && procd_append_param command -k $keepalive
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
socket = require("socket")
|
socket = require("socket")
|
||||||
|
|
||||||
|
-- get configs
|
||||||
|
|
||||||
|
local omit_zero_values = os.getenv("OMIT_ZERO_VALUES") == "1"
|
||||||
|
|
||||||
-- Parsing
|
-- Parsing
|
||||||
|
|
||||||
function space_split(s)
|
function space_split(s)
|
||||||
@@ -50,8 +54,12 @@ end
|
|||||||
|
|
||||||
function metric(name, mtype, labels, value)
|
function metric(name, mtype, labels, value)
|
||||||
out:write("# TYPE ", name, " ", mtype, "\n")
|
out:write("# TYPE ", name, " ", mtype, "\n")
|
||||||
|
-- omit_zero_vales config supress time series always being zero
|
||||||
|
local printall = not (mtype == "counter" and omit_zero_values)
|
||||||
local outputter = function(labels, value)
|
local outputter = function(labels, value)
|
||||||
print_metric(name, labels, value)
|
if printall or tonumber(value) ~= 0 then
|
||||||
|
print_metric(name, labels, value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if value then
|
if value then
|
||||||
outputter(labels, value)
|
outputter(labels, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user