Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for collecting DHCP metrics from Kea Control Agent #2937

Draft
wants to merge 77 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
301006f
Add dataclasses for queries to and responses from the Kea REST api
jorund1 Jun 18, 2024
85823db
Add dataclasses for Kea subnets and Kea DHCP config files
jorund1 Jun 25, 2024
e6ef7ad
Rename kea_stats.py to dhcp/kea_dhcp_data.py
jorund1 Jun 25, 2024
08639a3
Add superclass for all classes that fetch dhcp metrics
jorund1 Jun 25, 2024
a0edbc0
Sort import statements
jorund1 Jun 25, 2024
4f47a30
Add comments and more precise typing to make intentions of DhcpMetric…
jorund1 Jun 25, 2024
879b6ba
Implement KeaDhcpMetricSource as subclass of DhcpMetricSource
jorund1 Jun 25, 2024
48ebfcf
Remove "free addresses" as a Dhcp metric key temporarily
jorund1 Jun 26, 2024
1f65f3f
Finish metric extraction from configured subnets
jorund1 Jun 26, 2024
3c39713
Rename fetch_dhcp_config() to set_and_fetch_dhcp_config()
jorund1 Jun 26, 2024
fdc497d
Collect metrics per subnet instead of per vlan in DhcpMetricSource
jorund1 Jun 26, 2024
29b82e8
Check if config hash on local and on server is equal before fetching …
jorund1 Jun 26, 2024
03f2b8c
Warn if config changed on server during fetching of metrics
jorund1 Jun 26, 2024
4ce605f
Rewrite tests to work with newest code
jorund1 Jun 27, 2024
0ca7edc
Update kea_dhcp_data tests to work with most recent changes
jorund1 Jun 28, 2024
c3e34ea
Update variable names
jorund1 Jun 28, 2024
85da641
Move error checks done after send_query() calls to a new function
jorund1 Jun 28, 2024
542038e
Update comments
jorund1 Jun 28, 2024
e6fbcf4
Find subnets defined in shared-networks section of Kea DHCP config
jorund1 Jul 1, 2024
3a462ac
Add exception handling in the fetch_metrics method of KeaDhcpMetricSo…
jorund1 Jul 1, 2024
ae12df1
Use instance variables instead of function parameters in fetch_metrics
jorund1 Jul 1, 2024
6775dd9
Change ValueErrors to KeaErrors
jorund1 Jul 1, 2024
71fdf41
Be less strict when typing JSON dicts
jorund1 Jul 1, 2024
302553e
Exception handlers use `logger.debug` if they reraise exception
jorund1 Jul 1, 2024
0d69b06
Add timeouts to http requests
jorund1 Jul 1, 2024
d4b14c2
Fix (most) pylint errors
jorund1 Jul 1, 2024
87d90c5
Remove unnessecary comments
jorund1 Jul 1, 2024
0f81e5e
Rename kea_dchp_data.py to kea_metrics.py
jorund1 Jul 1, 2024
6d5242a
Use dhcp_version instead of ip_version to avoid ambiguities
jorund1 Jul 1, 2024
363971c
Fix linting errors
jorund1 Jul 1, 2024
14fe7d7
Move helper functions and helper dataclasses down
jorund1 Jul 3, 2024
f02b64a
Streamline logging and exception handling
jorund1 Jul 3, 2024
9456aa8
Add dhcp6 config test
jorund1 Jul 3, 2024
95e18ad
Add tests
jorund1 Jul 4, 2024
bf1e7df
Simplify kea dhcp module and remove unnecessary cruft
jorund1 Jul 4, 2024
6e3a2bf
Update error checking in `send_query()`
jorund1 Jul 5, 2024
51b7001
Add docstrings
jorund1 Jul 5, 2024
27161a7
Implement `fetch_config()` and `fetch_config_hash()`
jorund1 Jul 5, 2024
07dbb95
Add docstrings
jorund1 Jul 5, 2024
c590723
Remove class variables
jorund1 Jul 22, 2024
6c92967
Start private (helper) functions' names with underscore
jorund1 Jul 22, 2024
0b2d5c7
Add imports
jorund1 Jul 22, 2024
760e44d
Fix naming and syntax errors
jorund1 Jul 22, 2024
b05e6f8
Fix linting errors
jorund1 Jul 22, 2024
c6bfada
Use nav.metrics.names.escape_metric_name() instead of manual escape
jorund1 Jul 22, 2024
79392cd
Dump
jorund1 Jul 22, 2024
fe196d3
Use full ipaddress string in graphite path
jorund1 Jul 23, 2024
e6d75bd
Make DhcpMetric hashable and immutable
jorund1 Jul 23, 2024
8dacb95
Rewrite tests
jorund1 Jul 23, 2024
65a4941
Fix constant modified-config-during-metric-fetch error logging
jorund1 Jul 23, 2024
7181241
Use datetime instances with timezone data instead of unix timestamps.
jorund1 Jul 23, 2024
4f7a32c
Fail if status of a config's response is not SUCCESS
jorund1 Jul 23, 2024
cac787d
Rename variables and tidy up code
jorund1 Jul 23, 2024
3eafeb6
Adjust documentation
jorund1 Jul 23, 2024
92f54e1
Fix linting errors
jorund1 Jul 23, 2024
6a4b5eb
Fix imports
jorund1 Jul 24, 2024
3582bd3
Return List type, not Iterator in kea_metrics.fetch_metrics
jorund1 Jul 24, 2024
5826f22
Enhance docstrings
jorund1 Jul 24, 2024
30297e0
Alter exception handling
jorund1 Jul 24, 2024
a9509fb
Rename keys in DhcpMetricKey and remove TOUCH key
jorund1 Jul 26, 2024
17b5a81
Use NAVs configured carbon host and port by default when sending metrics
jorund1 Jul 26, 2024
1b0d670
Update docstrings
jorund1 Jul 26, 2024
2a5191e
Do not log the contents of a http request / response
jorund1 Jul 26, 2024
bea8d67
Actually raise a KeaException on HTTP response error statuses
jorund1 Jul 26, 2024
963e326
Fix wrong usage of str.join() function
jorund1 Jul 26, 2024
9b77b90
Add the ability to supply response attributes in our HTTP mock
jorund1 Jul 26, 2024
3dd8472
Add test that assures that KeaException bubbles up on any HTTP error
jorund1 Jul 26, 2024
8d5281b
Fix linting errors
jorund1 Jul 26, 2024
df18080
Declare and use dhcp metric path in nav.metrics.templates
jorund1 Jul 29, 2024
7322f4f
Change dhcp subnet metric path to include IP address and port
jorund1 Sep 20, 2024
3fd40e0
Set http requests' content-type to JSON
jorund1 Sep 20, 2024
3fb60a4
Use numeric timestamp instead of datetime instances for dhcp metrics
jorund1 Sep 20, 2024
76da903
Make linter happy
jorund1 Sep 20, 2024
8a3030e
Update canonical dhcp metric path template's docstring
jorund1 Sep 20, 2024
9b7dc94
Enhance docstrings, using suggestions from PEP 257
jorund1 Sep 20, 2024
000f4df
Disinclude ip-address and tcp-port from graphite dhcp metric path
jorund1 Sep 20, 2024
d3faa81
Extract a fetch_subnet_metrics() help-func out from fetch_metrics()
jorund1 Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set http requests' content-type to JSON
jorund1 committed Sep 20, 2024
commit 3fd40e0a59198dcc267456f54c942e970df956a8
1 change: 1 addition & 0 deletions python/nav/dhcp/kea_metrics.py
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ def _send_query(self, session: requests.Session, command: str, **kwargs) -> dict
self.rest_uri,
data=post_data,
timeout=self.timeout,
headers={"Content-Type": "application/json"},
)
request_summary["Status"] = "complete"
request_summary["HTTP Status"] = responses.status_code