diff --git a/.gitignore b/.gitignore index b345519fe2ddd4426c8d41cb1f3eb97c67ccedcb..3003120c6c0bdb1c94a342e6242cc6a5b08a1355 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ _test /docker/n9e /docker/mysqldata /docker/experience_pg_vm/pgdata -/etc.local +/etc.local* .alerts .idea diff --git a/alert/alert.go b/alert/alert.go index eb29946ba6b886e1c502af3de3d86f7bd1c19b02..d789012ec6634f1f8560335e71e9553ed04bb2e8 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -23,7 +23,6 @@ import ( "github.com/ccfos/nightingale/v6/prom" "github.com/ccfos/nightingale/v6/pushgw/pconf" "github.com/ccfos/nightingale/v6/pushgw/writer" - "github.com/ccfos/nightingale/v6/storage" ) func Initialize(configDir string, cryptoKey string) (func(), error) { @@ -39,15 +38,10 @@ func Initialize(configDir string, cryptoKey string) (func(), error) { ctx := ctx.NewContext(context.Background(), nil, false, config.CenterApi) - redis, err := storage.NewRedis(config.Redis) - if err != nil { - return nil, err - } - syncStats := memsto.NewSyncStats() alertStats := astats.NewSyncStats() - targetCache := memsto.NewTargetCache(ctx, syncStats, redis) + targetCache := memsto.NewTargetCache(ctx, syncStats, nil) busiGroupCache := memsto.NewBusiGroupCache(ctx, syncStats) alertMuteCache := memsto.NewAlertMuteCache(ctx, syncStats) alertRuleCache := memsto.NewAlertRuleCache(ctx, syncStats) diff --git a/etc/alert.toml.example b/etc/alert.toml.example new file mode 100644 index 0000000000000000000000000000000000000000..0ac109eec93e6b0078058ad149a55933f86dfc92 --- /dev/null +++ b/etc/alert.toml.example @@ -0,0 +1,60 @@ +[Global] +RunMode = "release" + +[CenterApi] +Addrs = ["http://127.0.0.1:17000"] +[CenterApi.BasicAuth] +user001 = "ccc26da7b9aba533cbb263a36c07dcc5" + +[Alert] +[Alert.Heartbeat] +# auto detect if blank +IP = "" +# unit ms +Interval = 1000 +EngineName = "default" + +[Log] +# log write dir +Dir = "logs" +# log level: DEBUG INFO WARNING ERROR +Level = "DEBUG" +# stdout, stderr, file +Output = "stdout" +# # rotate by time +# KeepHours = 4 +# # rotate by size +# RotateNum = 3 +# # unit: MB +# RotateSize = 256 + +[HTTP] +# http listening address +Host = "0.0.0.0" +# http listening port +Port = 17001 +# https cert file path +CertFile = "" +# https key file path +KeyFile = "" +# whether print access log +PrintAccessLog = false +# whether enable pprof +PProf = false +# expose prometheus /metrics? +ExposeMetrics = true +# http graceful shutdown timeout, unit: s +ShutdownTimeout = 30 +# max content length: 64M +MaxContentLength = 67108864 +# http server read timeout, unit: s +ReadTimeout = 20 +# http server write timeout, unit: s +WriteTimeout = 40 +# http server idle timeout, unit: s +IdleTimeout = 120 + +[HTTP.Alert] +Enable = true +[HTTP.Alert.BasicAuth] +user001 = "ccc26da7b9aba533cbb263a36c07dcc5" \ No newline at end of file diff --git a/etc/pushgw.toml.example b/etc/pushgw.toml.example new file mode 100644 index 0000000000000000000000000000000000000000..951111af986c5a5fd782115c02c8acb000a1c419 --- /dev/null +++ b/etc/pushgw.toml.example @@ -0,0 +1,103 @@ +[Global] +RunMode = "release" + +[CenterApi] +Addrs = ["http://127.0.0.1:17000"] +[CenterApi.BasicAuth] +user001 = "ccc26da7b9aba533cbb263a36c07dcc5" + +[Pushgw] +# use target labels in database instead of in series +LabelRewrite = true +# # default busigroup key name +# BusiGroupLabelKey = "busigroup" +# ForceUseServerTS = false + +# [Pushgw.DebugSample] +# ident = "xx" +# __name__ = "xx" + +# [Pushgw.WriterOpt] +# # Writer Options +# QueueCount = 1000 +# QueueMaxSize = 1000000 +# QueuePopSize = 1000 +# # ident or metric +# ShardingKey = "ident" + +[[Pushgw.Writers]] +# Url = "http://127.0.0.1:8480/insert/0/prometheus/api/v1/write" +Url = "http://127.0.0.1:9090/api/v1/write" +# Basic auth username +BasicAuthUser = "" +# Basic auth password +BasicAuthPass = "" +# timeout settings, unit: ms +Headers = ["X-From", "n9e"] +Timeout = 10000 +DialTimeout = 3000 +TLSHandshakeTimeout = 30000 +ExpectContinueTimeout = 1000 +IdleConnTimeout = 90000 +# time duration, unit: ms +KeepAlive = 30000 +MaxConnsPerHost = 0 +MaxIdleConns = 100 +MaxIdleConnsPerHost = 100 +## Optional TLS Config +# UseTLS = false +# TLSCA = "/etc/n9e/ca.pem" +# TLSCert = "/etc/n9e/cert.pem" +# TLSKey = "/etc/n9e/key.pem" +# InsecureSkipVerify = false +# [[Writers.WriteRelabels]] +# Action = "replace" +# SourceLabels = ["__address__"] +# Regex = "([^:]+)(?::\\d+)?" +# Replacement = "$1:80" +# TargetLabel = "__address__" + +[Log] +# log write dir +Dir = "logs" +# log level: DEBUG INFO WARNING ERROR +Level = "DEBUG" +# stdout, stderr, file +Output = "stdout" +# # rotate by time +# KeepHours = 4 +# # rotate by size +# RotateNum = 3 +# # unit: MB +# RotateSize = 256 + +[HTTP] +# http listening address +Host = "0.0.0.0" +# http listening port +Port = 17000 +# https cert file path +CertFile = "" +# https key file path +KeyFile = "" +# whether print access log +PrintAccessLog = false +# whether enable pprof +PProf = false +# expose prometheus /metrics? +ExposeMetrics = true +# http graceful shutdown timeout, unit: s +ShutdownTimeout = 30 +# max content length: 64M +MaxContentLength = 67108864 +# http server read timeout, unit: s +ReadTimeout = 20 +# http server write timeout, unit: s +WriteTimeout = 40 +# http server idle timeout, unit: s +IdleTimeout = 120 + +[HTTP.Pushgw] +Enable = true +# [HTTP.Pushgw.BasicAuth] +# user001 = "ccc26da7b9aba533cbb263a36c07dcc5" \ No newline at end of file