-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.go
48 lines (39 loc) · 1.01 KB
/
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
44
45
46
47
48
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/Chainflow/solana-mission-control/config"
"github.com/Chainflow/solana-mission-control/exporter"
"github.com/Chainflow/solana-mission-control/monitor"
)
func main() {
cfg, err := config.ReadFromFile() // Read config file
if err != nil {
log.Fatal(err)
}
collector := exporter.NewSolanaCollector(cfg)
go collector.WatchSlots(cfg)
// Calling command based alerting
go func() {
for {
monitor.TelegramAlerting(cfg)
time.Sleep(2 * time.Second)
}
}()
go func() {
for {
monitor.SkipRateAlerts(cfg)
time.Sleep(60 * time.Second)
}
}()
prometheus.MustRegister(collector)
http.Handle("/metrics", promhttp.Handler()) // exported metrics can be seen in /metrics
err = http.ListenAndServe(fmt.Sprintf("%s", cfg.Prometheus.ListenAddress), nil)
if err != nil {
log.Printf("Error while listening on server : %v", err)
}
}