fixes
This commit is contained in:
1 parent
f30adf05af
commit
8824af8699
29 files changed
+1201
-115
No files matched your search
@@ -52,6 +52,7 @@ func main() {
|
||||
cfg := features.SpikeConfig{Window: *window, BaselineWindows: *baselineWindows, Multiple: *multiple, MinExcess: *minExcess}
|
||||
|
||||
events := load(*addr, *database, *user, *password, start, end)
|
||||
cfg.DataSince = dataSince(*addr, *database, *user, *password)
|
||||
log.Printf("loaded %d error events", len(events))
|
||||
|
||||
cache := map[string]classification{}
|
||||
@@ -212,3 +213,23 @@ func envOr(k, f string) string {
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// dataSince returns the earliest normalized row, used as the warm-up guard.
|
||||
func dataSince(addr, database, user, password string) time.Time {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
conn, err := clickhouse.Open(&clickhouse.Options{Addr: []string{addr}, Auth: clickhouse.Auth{Database: database, Username: user, Password: password}})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
var t time.Time
|
||||
if err := conn.QueryRow(ctx, fmt.Sprintf(`SELECT min(timestamp) FROM %s.normalized_events`, database)).Scan(&t); err != nil {
|
||||
log.Printf("warm-up guard disabled: %v", err)
|
||||
return time.Time{}
|
||||
}
|
||||
if t.Year() < 2000 { // empty table
|
||||
return time.Time{}
|
||||
}
|
||||
return t
|
||||
}
|
||||
Reference in new issue
Block a user