【问题标题】:Is there an arg to set other endpoint in start_http_server (prometheus_client) instead of /?是否有一个参数可以在 start_http_server (prometheus_client) 而不是 / 中设置其他端点?
【发布时间】:2018-08-30 18:26:58
【问题描述】:

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

谢谢!

【问题讨论】:

    标签: python flask instrumentation prometheus


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多