From 02d02463f7fce5b8d0a08ca9826bc9cf2bc4ebe6 Mon Sep 17 00:00:00 2001 From: ning <710leo@gmail.com> Date: Tue, 21 Mar 2023 16:33:06 +0800 Subject: [PATCH] fix: target insert --- alert/process/process.go | 4 ++++ go.mod | 4 ++-- pushgw/idents/idents.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/alert/process/process.go b/alert/process/process.go index 7b4d74e2..5c4b0c63 100644 --- a/alert/process/process.go +++ b/alert/process/process.go @@ -72,6 +72,10 @@ func (p *Processor) Key() string { return common.RuleKey(p.datasourceId, p.rule.Id) } +func (p *Processor) DatasourceId() int64 { + return p.datasourceId +} + func (p *Processor) Hash() string { return str.MD5(fmt.Sprintf("%d_%d_%s_%d", p.rule.Id, diff --git a/go.mod b/go.mod index 35ffa71f..fcf686a9 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/ccfos/nightingale/v6 go 1.18 require ( + github.com/BurntSushi/toml v0.3.1 github.com/coreos/go-oidc v2.2.1+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-contrib/pprof v1.4.0 github.com/gin-gonic/gin v1.8.2 github.com/go-ldap/ldap/v3 v3.4.4 - github.com/go-sql-driver/mysql v1.6.0 github.com/gogo/protobuf v1.3.2 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang/protobuf v1.5.2 @@ -35,7 +35,6 @@ require ( require ( github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect - github.com/BurntSushi/toml v0.3.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect @@ -46,6 +45,7 @@ require ( github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/goccy/go-json v0.9.11 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect diff --git a/pushgw/idents/idents.go b/pushgw/idents/idents.go index 992fb0ff..afcc0b7c 100644 --- a/pushgw/idents/idents.go +++ b/pushgw/idents/idents.go @@ -105,7 +105,7 @@ func (s *Set) updateTargets(lst []string, now int64) error { news := slice.SubString(lst, exists) for i := 0; i < len(news); i++ { - err = s.db.Exec("INSERT INTO target(ident, update_at, cluster) VALUES(?, ?, ?)", news[i], now, "").Error + err = s.db.Exec("INSERT INTO target(ident, update_at) VALUES(?, ?)", news[i], now).Error if err != nil { logger.Error("failed to insert target:", news[i], "error:", err) }