Closed Tira007 closed 4 years ago
This is probably due to new metrics, that kea-exporter does not handle (in this case ignore) yet. What Kea version is this?
I've added a patch for you to try in the pull request above.
I'm still seeing a KeyError with the patch applied.
I believe this is caused by a further instance of "cumulative-assigned-addresses" on each subnet which isn't captured by self.metrics_dhcp4_ignore.
echo '{ "command": "statistic-get-all" }' | socat UNIX:/sockets/kea-dhcp4-ctrl.sock -,ignoreeof | jq
{
"arguments": {
"cumulative-assigned-addresses": [
[
0,
"2020-08-05 11:14:44.552701"
]
],
...... omitted for brevity .......
],
"subnet[1].cumulative-assigned-addresses": [
[
0,
"2020-08-05 11:14:45.591529"
]
...... omitted for brevity .......
},
"result": 0
}
Here is the traceback:
Traceback (most recent call last):
File "/usr/bin/kea-exporter", line 11, in <module>
load_entry_point('kea-exporter==0.4.1', 'console_scripts', 'kea-exporter')()
File "/usr/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.8/site-packages/click-7.1.2-py3.8.egg/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/kea_exporter-0.4.1-py3.8.egg/kea_exporter/cli.py", line 22, in cli
File "/usr/lib/python3.8/site-packages/kea_exporter-0.4.1-py3.8.egg/kea_exporter/kea.py", line 506, in update
KeyError: 'cumulative-assigned-addresses'
Then we could apply the same ignore rules to the per subnet metrics. Can you try this?
diff --git a/kea_exporter/kea.py b/kea_exporter/kea.py
index decc023..031af0e 100644
--- a/kea_exporter/kea.py
+++ b/kea_exporter/kea.py
@@ -485,6 +485,14 @@ class KeaExporter:
subnet_id = int(match.group('subnet_id'))
key = match.group('metric')
+ if kea.dhcp_version is DHCPVersion.DHCP4:
+ if key in self.metrics_dhcp4_ignore:
+ continue
+ elif kea.dhcp_version is DHCPVersion.DHCP6:
+ if key in self.metrics_dhcp6_ignore:
+ continue
+ else:
+ continue
try:
subnet = kea.subnets[subnet_id]
except KeyError:
Yes, that resolves the issue. Thanks!
How to launch kea-exporter?
example 1
example2
I would be grateful for an example.