-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
30 lines (24 loc) · 884 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"log"
"net/http"
"github.com/claranet/wallix_bastion_exporter/config"
"github.com/claranet/wallix_bastion_exporter/exporter"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
cfg, err := config.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config:", err)
}
wallixExporter := exporter.NewExporter(cfg)
prometheus.MustRegister(wallixExporter)
log.Printf("Started %s exporter listening on %s%s\n", exporter.Namespace, cfg.ListenAddress, cfg.TelemetryPath)
http.Handle(cfg.TelemetryPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
// Allows to redirect from root to metric path
http.Redirect(w, req, cfg.TelemetryPath, http.StatusPermanentRedirect)
})
log.Fatal(http.ListenAndServe(cfg.ListenAddress, nil))
}