mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 06:58:39 +01:00
prometheus-node-exporter-lua: uci_dhcp_host module
Extract data from configuration file /etc/config/dhcp and create labels
{name, ip, mac, dns} via uci. Those labels are useful in order to craft
complex prometheus queries as replacing the MAC address to a custom
name. E.g.: wifi_station_signal_dbm * on (mac) group_left(name)
uci_dhcp_host or on (mac) label_replace(wifi_station_signal_dbm, "name",
"$1", "mac", "(.+)")
Signed-off-by: Gérondal Thibault <contact@tycale.be>
This commit is contained in:
committed by
Paul Spooren
parent
f4e878c215
commit
e2b3fec6bf
+15
@@ -0,0 +1,15 @@
|
||||
local uci=require("uci")
|
||||
|
||||
local function scrape()
|
||||
local curs=uci.cursor()
|
||||
local metric_uci_host = metric("uci_dhcp_host", "gauge")
|
||||
|
||||
curs:foreach("dhcp", "host", function(s)
|
||||
if s[".type"] == "host" then
|
||||
labels = {name=s["name"], mac=string.upper(s["mac"]), dns=s["dns"], ip=s["ip"]}
|
||||
metric_uci_host(labels, 1)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return { scrape = scrape }
|
||||
Reference in New Issue
Block a user