Add prometheus and disable http2

This commit is contained in:
Bolke de Bruin 2020-07-14 08:43:25 +02:00
parent 1f191a5e41
commit 33a5e0e03c
3 changed files with 43 additions and 5 deletions

11
main.go
View file

@ -3,6 +3,8 @@ package main
import (
"crypto/tls"
"flag"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/client_golang/prometheus"
"log"
"net/http"
"os"
@ -42,9 +44,16 @@ func main() {
server := http.Server{
Addr: ":" + strconv.Itoa(*port),
TLSConfig: cfg,
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), // disable http2
}
http.HandleFunc("/remoteDesktopGateway/", handleGatewayProtocol)
http.Handle("/metrics", promhttp.Handler())
prometheus.MustRegister(connectionCache)
prometheus.MustRegister(legacyConnections)
prometheus.MustRegister(websocketConnections)
err = server.ListenAndServeTLS("", "")
if err != nil {
log.Fatal("ListenAndServe: ", err)