aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()