是否有一个arg可以在start_http_server(prometheus_client)而非/中设置其他端点?

时间:2018-08-30 18:26:58

标签: python flask instrumentation prometheus

我正在构建一个Flask应用程序,我想知道模块start_http_server(来自prometheus_client)上是否有一个arg,该参数允许我设置特定的指标终结点/。

谢谢!

1 个答案:

答案 0 :(得分:0)

将Prometheus客户端与flask一起使用时,不需要自己启动http服务器,但是可以启用wsgi中间件并指定要在现有应用程序上提供指标的路由。

app = Flask(__name__)
app_dispatch = DispatcherMiddleware(app, {
  '/metrics': make_wsgi_app()
})

有关如何执行此操作的完整示例,只需查看python prometheus_client docs on flask