From 79d8aeee116fff855162b35e84008fcd78a93e54 Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Sat, 21 Nov 2020 00:43:33 +0800 Subject: [PATCH] monapi get index configurable --- src/modules/monapi/config/yaml.go | 2 ++ src/modules/monapi/http/router_index.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/monapi/config/yaml.go b/src/modules/monapi/config/yaml.go index 55d5b061..dc88a691 100644 --- a/src/modules/monapi/config/yaml.go +++ b/src/modules/monapi/config/yaml.go @@ -25,6 +25,7 @@ type ConfYaml struct { Merge mergeSection `yaml:"merge"` Notify map[string][]string `yaml:"notify"` Link linkSection `yaml:"link"` + IndexMod string `yaml:"indexMod"` } type mergeSection struct { @@ -136,6 +137,7 @@ func Parse(ymlfile string) error { }) viper.SetDefault("alarmEnabled", "true") + viper.SetDefault("indexMod", "index") viper.SetDefault("habits.identity", "ip") diff --git a/src/modules/monapi/http/router_index.go b/src/modules/monapi/http/router_index.go index c473b251..8b9569b0 100644 --- a/src/modules/monapi/http/router_index.go +++ b/src/modules/monapi/http/router_index.go @@ -9,6 +9,7 @@ import ( "github.com/didi/nightingale/src/common/dataobj" "github.com/didi/nightingale/src/common/report" "github.com/didi/nightingale/src/models" + "github.com/didi/nightingale/src/modules/monapi/config" "github.com/gin-gonic/gin" "github.com/toolkits/pkg/errors" @@ -128,7 +129,7 @@ func Tagkv(request NidMetricRecv) ([]IndexTagkvResp, error) { func GetIndexes() []string { var indexInstances []string - instances, err := report.GetAlive("index", "rdb") + instances, err := report.GetAlive(config.Get().IndexMod, "rdb") if err != nil { return indexInstances }