forked from kuskoman/logstash-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 997 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
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"log"
"github.com/joho/godotenv"
"github.com/kuskoman/logstash-exporter/collectors"
"github.com/kuskoman/logstash-exporter/config"
"github.com/kuskoman/logstash-exporter/server"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slog"
)
func main() {
warn := godotenv.Load()
if warn != nil {
log.Println(warn)
}
logger, err := config.SetupSlog()
if err != nil {
log.Fatalf("failed to setup slog: %s", err)
}
slog.SetDefault(logger)
port := config.Port
host := config.Host
logstashUrl := config.LogstashUrl
slog.Debug("Application starting... ")
versionInfo := config.GetVersionInfo()
slog.Info(versionInfo.String())
collectorManager := collectors.NewCollectorManager(logstashUrl)
server := server.NewAppServer(host, port)
prometheus.MustRegister(collectorManager)
slog.Info("Starting server on port", "port", port)
err = server.ListenAndServe()
if err != nil {
slog.Error("failed to listen and serve", "err", err)
}
}