|
6 | 6 | "strconv" |
7 | 7 | "time" |
8 | 8 |
|
9 | | - "github.com/fox-gonic/fox" |
| 9 | + "github.com/gin-gonic/gin" |
10 | 10 | alertapi "github.com/qiniu/zeroops/internal/alerting/api" |
11 | 11 | adb "github.com/qiniu/zeroops/internal/alerting/database" |
12 | 12 | "github.com/qiniu/zeroops/internal/alerting/service/healthcheck" |
@@ -96,22 +96,24 @@ func main() { |
96 | 96 | go rem.Start(ctx, alertCh) |
97 | 97 |
|
98 | 98 | // start Prometheus anomaly detection scheduler |
99 | | - promInterval := parseDuration(cfg.Alerting.Prometheus.SchedulerInterval, 6*time.Hour) |
| 99 | + promInterval := parseDuration(cfg.Alerting.Prometheus.SchedulerInterval, 5*time.Minute) |
100 | 100 | promStep := parseDuration(cfg.Alerting.Prometheus.QueryStep, time.Minute) |
101 | 101 | promRange := parseDuration(cfg.Alerting.Prometheus.QueryRange, 6*time.Hour) |
102 | 102 | promCfg := healthcheck.NewPrometheusConfigFromApp(&cfg.Alerting.Prometheus) |
103 | | - promClient := healthcheck.NewPrometheusClient(promCfg) |
| 103 | + anomalyDetectClient := healthcheck.NewAnomalyDetectClient(promCfg) |
104 | 104 | go healthcheck.StartPrometheusScheduler(ctx, healthcheck.PrometheusDeps{ |
105 | | - DB: alertDB, |
106 | | - PrometheusClient: promClient, |
107 | | - Interval: promInterval, |
108 | | - QueryStep: promStep, |
109 | | - QueryRange: promRange, |
110 | | - RulesetBase: cfg.Alerting.Ruleset.APIBase, |
111 | | - RulesetTimeout: parseDuration(cfg.Alerting.Ruleset.APITimeout, 10*time.Second), |
| 105 | + DB: alertDB, |
| 106 | + AnomalyDetectClient: anomalyDetectClient, |
| 107 | + Interval: promInterval, |
| 108 | + QueryStep: promStep, |
| 109 | + QueryRange: promRange, |
| 110 | + RulesetBase: cfg.Alerting.Ruleset.APIBase, |
| 111 | + RulesetTimeout: parseDuration(cfg.Alerting.Ruleset.APITimeout, 10*time.Second), |
112 | 112 | }) |
113 | 113 |
|
114 | | - router := fox.New() |
| 114 | + router := gin.New() |
| 115 | + router.Use(gin.Logger()) |
| 116 | + router.Use(gin.Recovery()) |
115 | 117 | router.Use(middleware.Authentication) |
116 | 118 | alertapi.NewApiWithConfig(router, cfg) |
117 | 119 | if err := serviceManagerSrv.UseApi(router); err != nil { |
|
0 commit comments