-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (29 loc) · 813 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
package main
import (
"net/http"
"os"
"github.com/go-chi/chi"
"github.com/mperkins808/log-based-metric-exporter/server/pkg/api/healthy"
"github.com/mperkins808/log-based-metric-exporter/server/pkg/engine"
m "github.com/mperkins808/log-based-metric-exporter/server/pkg/metrics"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
)
func main() {
mux := chi.NewRouter()
// Routes
mux.Get("/healthy", healthy.Healthy)
mux.Get("/metrics", func(w http.ResponseWriter, r *http.Request) {
promhttp.Handler().ServeHTTP(w, r)
m.ResetPrometheusGauges()
})
// ENGINE
go engine.RuleEngine()
PORT := os.Getenv("PORT")
if PORT == "" {
PORT = "10015"
}
log.Infof("Starting server on :%v", PORT)
err := http.ListenAndServe(":"+PORT, mux)
log.Fatal(err)
}