aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgenofire <geno+dev@fireorbit.de>2020-06-09 20:56:01 +0200
committergenofire <geno+dev@fireorbit.de>2020-06-09 20:56:01 +0200
commit7ca08b12c0bcb1d69d0b04e4201f813b85dc75d0 (patch)
treeb3a434f01ba0bbc892a3292c6caf87f6c97ca85f
parent710e139403c67fcf889857483276b1e5f6e18c87 (diff)
fix ipv6 support for prometheus
-rwxr-xr-xprometheus.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/prometheus.py b/prometheus.py
index 9e45d69..007b4f6 100755
--- a/prometheus.py
+++ b/prometheus.py
@@ -6,6 +6,7 @@ import logging
from time import time
from collections import defaultdict
from http.server import BaseHTTPRequestHandler, HTTPServer
+from socket import AF_INET6
from urllib.parse import parse_qs, urlparse
from prometheus_client import (
CollectorRegistry, Gauge, generate_latest, CONTENT_TYPE_LATEST
@@ -96,6 +97,8 @@ class Prometheus():
return registry
def listen(self, addr=("127.0.0.1", 8080)):
+ if "::" in addr[0]:
+ HTTPServer.address_family = AF_INET6
server = HTTPServer(addr, DynamicMetricsHandler.factory(self.handler))
server.serve_forever()