0

I am trying to configure prometheues into a .Net Core 3.1 Application. My application runs on http2 protocol and I have the below configuration in appsetting.json.

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

However, I am unable to get the service up and running in prometheus UI.(I queried "up" to check the server running status). I am getting a following message in the prometheus log.

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

If I set the protocol as Http1AndHttp2 am getting the service up and running in prometheus. But I need the service to be up when only http2 protocol is supported.

Please also find the config that I have done in my prometheus.yml

  - job_name: "service"

    # metrics_path defaults to '/metrics'
    scheme: https
    tls_config:
      insecure_skip_verify: true    
    static_configs:
      - targets: 
        - localhost:5001
Swaroop
  • 501
  • 5
  • 18

2 Answers2

1

At the moment, Prometheus does not support HTTP/2 by default, which may be the problem. In the next release (v2.31) it will be enabled again, but for now, with the latest release (v2.30) you can set the PROMETHEUS_COMMON_ENABLE_HTTP2 environment variable to a non-blank value to enable it.

Levi Harrison
  • 493
  • 3
  • 10
0

You can edit the appsettings.json file is such a way that makes the Kestrel expose an additional port which uses HTTP/1 protocol by default. You can use your original port for your usual business and the other one for Prometheus.

(Tested in .net5)

"Kestrel": {
  "EndpointDefaults": {
    "Protocols": "Http2"
  },
  "Endpoints": {
    "Http1": {
      "Url": "http://0.0.0.0:5420",
      "Protocols": "Http1"
    },
    "Http": {
      "Url": "http://0.0.0.0:5000",
    },
    "Https": {
      "Url": "https://0.0.0.0:5001"
    }
  }
}
LilacBlue
  • 173
  • 1
  • 9