Releases: wacken89/hetzner-load-balancer-prometheus-exporter
v1.5.4
Robustness and modernization release. Closes #22, #23, #27, #28.
Highlights
- No more crashes on empty metrics. The exporter used to die with
IndexErrorwhen Hetzner returned an emptyvalues: []for any metric (common on freshly-created load balancers with no traffic). Gauges are now safely skipped on missing data instead of crashing the process. - No more crashes at startup on empty projects. A missing
serverskey in the Hetzner API response no longer takes the exporter down withKeyError: 'servers'. The server-name cache degrades gracefully to empty with a warning. - Python 3.12. Base image bumped from
python:3.8-slim(EOL October 2024) topython:3.12-slim. Dependencies pinned with floors to keep the wheels compatible going forward.
What's new
Bug fixes
- Fix
IndexError: list index out of rangeon empty metric values (#27). Replaced fragile["values"][0][1]indexing with a guardedextract_latest_metric_value()helper. When the time series is empty, missing, or malformed, the gauge is skipped for that tick — Prometheus keeps the previous sample via its normal staleness handling. - Fix
KeyError: 'servers'at startup (#28).get_all_server_names()now tolerates responses without aserverskey (empty projects, transient API hiccups) and starts with an empty server-name cache instead of crashing. - Fix latest-vs-first datapoint. The previous
[0][1]indexing returned the oldest point in the hour-long window. Gauges now report the most recent datapoint, which matches what Prometheus expects. - Fix hard-coded version metric.
hetzner_load_balancer_info{version="1.2.0"}was stale through every release since v1.2.0. Version is now centralized in a single constant.
Improvements
- HTTP timeouts on every Hetzner API call. All
requests.get()calls now have a 15-second timeout. Previously, a slow or unresponsive Hetzner API could hang the exporter indefinitely with no scrapes happening. - Halved bandwidth API calls.
bandwidth.inandbandwidth.outcome from the same/metrics?type=bandwidthresponse. The exporter now fetches it once per scrape per load balancer instead of twice — half the API traffic for the bandwidth path, easier on rate limits. - Centralized HTTP layer. All Hetzner API calls go through a single
_api_get()function with consistent timeout, error handling, and structured logging on failures. Easier to extend and easier to debug. - More defensive
.get()access. Optional fields (load_balancer,targets,services,health_status) are accessed with.get()defaults throughout, so partial or unexpected API responses produce warnings rather than tracebacks. - Stdout flushed immediately.
PYTHONUNBUFFERED=1added to the Dockerfile, so logs show up inkubectl logsanddocker logswithout buffering delay.
Maintenance
-
Remove unused
get_server_info()(#22). Dead code; not referenced anywhere in the repo. -
Bump base image to
python:3.12-slim(#23). Python 3.8 reached end-of-life in October 2024. -
Pin runtime dependencies to versions compatible with Python 3.12:
prometheus_client>=0.20.0,<1.0.0requests>=2.32.0,<3.0.0urllib3>=2.2.0,<3.0.0
This avoids the
ModuleNotFoundError: No module named 'urllib3.packages.six.moves'that appeared when the unpinned oldurllib3<1.26was installed under Python 3.12.
Breaking changes
None. All metric names, label sets, and environment variables are unchanged. Existing Grafana dashboards, alerting rules, and Helm values.yaml files continue to work without modification.
Behavior change worth noting
When Hetzner returns no data for a metric (e.g., a brand-new load balancer with zero traffic), the corresponding gauge is no longer set for that scrape cycle. Prometheus will report the previous value as stale after its normal staleness window (5 minutes by default) instead of 0 or a crash. This is the standard exporter pattern and matches node_exporter / kube-state-metrics behavior.
Upgrading
docker pull wacken/hetzner-load-balancer-prometheus-exporter:v1.5.4Or in kubernetes.yaml / Helm values.yaml:
image:
repository: wacken/hetzner-load-balancer-prometheus-exporter
tag: v1.5.4No configuration changes required.
Container
wacken/hetzner-load-balancer-prometheus-exporter:v1.5.4wacken/hetzner-load-balancer-prometheus-exporter:latest- Base:
python:3.12-slim
Contributors
- Inspiration and a working approach to the
IndexErrorfix from @mbirchdk in #32 — thank you! - Issue reports from @orehoj, @clementblaise, @hegerdes, @ivan-piskunov-betpawa.
Full changelog
v1.5.3
v1.5.2
v1.5.1
hetzner-load-balancer-exporter-1.5.0
Hetzner Load Balancer Prometheus Exporter
v1.5.0
hetzner-load-balancer-exporter-1.3.0
Hetzner Load Balancer Prometheus Exporter