mweinelt / kea-exporter

Export Kea Metrics in the Prometheus Exposition Format
MIT License
34 stars 17 forks source link

Wrong value calculation on DHCP pool #46

Closed M0NsTeRRR closed 8 months ago

M0NsTeRRR commented 8 months ago

In my setup, I have a subnet (192.168.50.0/24) with a limited DHCP range (192.168.50.201-192.168.50.240). Additionally, I have static DHCP entries that are not within the DHCP range for IoT devices that cannot have static IP addresses configured. The issue is that the two pools have the same values when they should not.

kea-leases.csv

192.168.50.101,98:da:c4:be:e8:89,01:98:da:c4:be:e8:89,4000,1710894279,3,0,0,hs110-rack1,0,,0
192.168.50.102,98:da:c4:be:e8:96,01:98:da:c4:be:e8:96,4000,1710894318,3,0,0,hs110-rack2,0,,0
192.168.50.103,98:da:c4:be:e9:ea,01:98:da:c4:be:e9:ea,4000,1710894167,3,0,0,hs110-chambre1,0,,0
192.168.50.104,48:e1:e9:dc:96:1e,,4000,1710893796,3,0,0,meross-tireuse,0,,0
192.168.50.105,48:e1:e9:dc:9e:a5,,4000,1710893811,3,0,0,meross-monsieur-cuisine,0,,0
192.168.50.111,04:cf:8c:b5:1e:17,,4000,1710893677,3,0,0,xiaomi-bulb-chambre1,0,,0
192.168.50.112,64:90:c1:6a:f0:98,01:64:90:c1:6a:f0:98,4000,1710894159,3,0,0,xiaomi-vaccum,0,,0
192.168.50.113,ec:4d:3e:28:c2:23,,4000,1710894244,3,0,0,xiaomi-bulb-salon,0,,0
192.168.50.114,b4:60:ed:45:50:00,,4000,1710894056,3,0,0,xiaomi-light-bar,0,,0
192.168.50.115,58:b6:23:ed:62:ce,,4000,1710893882,3,0,0,xiaomi-led-chambre1,0,,0
192.168.50.116,58:b6:23:ed:8a:df,,4000,1710893910,3,0,0,xiaomi-led-bar,0,,0
192.168.50.117,ec:4d:3e:56:b5:9d,01:ec:4d:3e:56:b5:9d,4000,1710893826,3,0,0,xiaomi-lamp-salon,0,,0
192.168.50.118,b4:60:ed:13:99:f9,01:b4:60:ed:13:99:f9,4000,1710894043,3,0,0,xiaomi-lamp-cuisine,0,,0
192.168.50.119,ec:4d:3e:2a:c7:18,,4000,1710894063,3,0,0,xiaomi-bulb-entree,0,,0
192.168.50.201,c8:2a:dd:8f:13:62,01:c8:2a:dd:8f:13:62,4000,1710892943,3,0,0,pixel-7,0,,0
192.168.50.202,44:5c:e9:51:14:10,01:44:5c:e9:51:14:10,4000,1710893007,3,0,0,samsung,0,,0
192.168.50.217,48:b0:2d:2d:9c:09,01:48:b0:2d:2d:9c:09,4000,1710893670,3,0,0,,0,,0
192.168.50.220,42:6c:fe:7a:fb:ea,01:42:6c:fe:7a:fb:ea,4000,1710893882,3,0,0,,0,,0
192.168.50.231,9c:28:41:09:42:9b,,4000,1710893356,3,0,0,mcsmartmcsmart30202123y3l625,0,,0

The second metric should have a value of 5

kea_dhcp4_addresses_assigned_total{pool="",subnet="192.168.50.0/24",subnet_id="3"} 19.0
kea_dhcp4_addresses_assigned_total{pool="192.168.50.201-192.168.50.240",subnet="192.168.50.0/24",subnet_id="3"} 19.0

The first metric should have a value of 254

kea_dhcp4_addresses_total{pool="",subnet="192.168.50.0/24",subnet_id="3"} 40.0
kea_dhcp4_addresses_total{pool="192.168.50.201-192.168.50.240",subnet="192.168.50.0/24",subnet_id="3"} 40.0
mweinelt commented 8 months ago

I don't think the calculation is ours. Unless we mismatch a metric. Can you look at the raw metrics as requested from the UDS or HTTP API?

M0NsTeRRR commented 8 months ago

Indeed, that's what the API reports. I didn't understand the metric that way, but it seems that the metrics do not take static IPs into account.

So for example, this metric kea_dhcp4_addresses_assigned_total{pool="",subnet="192.168.50.0/24",subnet_id="3"} 19.0 returns the number of IP addresses assigned across all configured DHCP pools.

Sorry for the false alarm, but it looked really strange. Thanks for your quick response.