【问题标题】:Prometheus Net AspNet Core not supporting http2 protocolPrometheus Net AspNet Core 不支持 http2 协议
【发布时间】:2021-10-06 10:48:22
【问题描述】:

我正在尝试将 prometheues 配置到 .Net Core 3.1 应用程序中。我的应用程序在 http2 协议上运行,并且我在 appsetting.json 中有以下配置。

  "Kestrel": {
    "EndpointDefaults": {
      "Protocols": "Http2"
    }
  },

但是,我无法在 prometheus UI 中启动并运行该服务。(我查询“up”以检查服务器运行状态)。我在 prometheus 日志中收到以下消息。

caller=tls_config.go:191 component=web msg="TLS is disabled." http2=false

如果我将协议设置为 Http1AndHttp2,我会在 prometheus 中启动并运行该服务。但是当只支持 http2 协议时,我需要启动服务。

还请在我的 prometheus.yml 中找到我所做的配置

  - job_name: "service"

    # metrics_path defaults to '/metrics'
    scheme: https
    tls_config:
      insecure_skip_verify: true    
    static_configs:
      - targets: 
        - localhost:5001

【问题讨论】:

    标签: prometheus asp.net-core-3.1 prometheus-net


    【解决方案1】:

    目前,Prometheus 默认不支持 HTTP/2,这可能是问题所在。在下一个版本 (v2.31) 中,它将再次启用,但现在,在最新版本 (v2.30) 中,您可以将 PROMETHEUS_COMMON_ENABLE_HTTP2 环境变量设置为非空值以启用它。

    【讨论】:

    • 它适用于 promethus 2.29 版,使用您提到的 Environment 变量。谢谢!!
    • 嗯,我不认为那个补丁已经成功了,但我猜它已经成功了。
    • 实际上由于某种原因在 2.30 版本中它不起作用但在 2.29 中起作用。
    猜你喜欢
    • 2015-09-11
    • 2015-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多