Add HTTPS configuration

Add the exporter-toolkit https package to allow configuring TLS and
auth.

Signed-off-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Calle Pettersson <carlpett@users.noreply.github.com>
This commit is contained in:
Ben Kochie
2021-01-03 15:54:32 +01:00
committed by Calle Pettersson
parent 4b66473d2e
commit cdc81b03d5
4 changed files with 33 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
"github.com/prometheus/exporter-toolkit/https"
"gopkg.in/alecthomas/kingpin.v2"
)
@@ -258,6 +259,10 @@ func main() {
"config.file",
"YAML configuration file to use. Values set in this file will be overriden by CLI flags.",
).String()
httpsConfig = kingpin.Flag(
"web.config",
"[EXPERIMENTAL] Path to config yaml file that can enable TLS or authentication.",
).Default("").String()
listenAddress = kingpin.Flag(
"telemetry.addr",
"host:port for exporter.",
@@ -398,7 +403,10 @@ func main() {
go func() {
log.Infoln("Starting server on", *listenAddress)
log.Fatalf("cannot start windows_exporter: %s", http.ListenAndServe(*listenAddress, nil))
server := &http.Server{Addr: *listenAddress}
if err := https.Listen(server, *httpsConfig, logger); err != nil {
log.Fatalf("cannot start windows_exporter: %s", err)
}
}()
for {