I am writing a custom exporter for my application using the official Python client for Prometheus My code works fine with the below snippet, (I'm redacting the rest of the code as I think it is irrelevant to the issue I'm facing.)
from prometheus_client import start_http_server, Gauge
start_http_server(9669)
I'm able to get the response if I do
curl --noproxy "*" -v http://localhost:9669/metrics
from the same machine. The issue here is my servers on IPv6. So this endpoint is not reachable from the server where I have Prometheus running. How can make
start_http_server
on IPv6 or is there a workaround for this?
I tried running a flask app and doing curl from the machine where I have Prometheus installed. I do not get response for
from flask import Flask
app = Flask(__name__)
@app.route('/hello')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8989)
but I get response if I modify the line to
app.run(host='::', port=8989)
So I figured I need to run the Prometheus
start_http_server
on IPv6. I tried
start_http_server(9669, addr='[::]')
but I get the error
socket.gaierror: [Errno -2] Name or service not known
and for
start_http_server(9669, addr='::')
I get the error
socket.gaierror: [Errno -9] Address family for hostname not supported