diff --git a/etc/server.conf b/etc/server.conf index fb440362..8c651ffb 100644 --- a/etc/server.conf +++ b/etc/server.conf @@ -4,6 +4,10 @@ RunMode = "release" # my cluster name ClusterName = "Default" +# Default busigroup Key name +# do not change +BusiGroupLabelKey = "busigroup" + # sleep x seconds, then start judge engine EngineDelay = 120 diff --git a/src/server/common/label_append.go b/src/server/common/label_append.go index 2617ad0b..d1574315 100644 --- a/src/server/common/label_append.go +++ b/src/server/common/label_append.go @@ -2,6 +2,7 @@ package common import ( "github.com/didi/nightingale/v5/src/models" + "github.com/didi/nightingale/v5/src/server/config" "github.com/didi/nightingale/v5/src/server/memsto" "github.com/prometheus/prometheus/prompb" ) @@ -18,7 +19,7 @@ func AppendLabels(pt *prompb.TimeSeries, target *models.Target) { }) } - if target.GroupId > 0 { + if target.GroupId > 0 && len(config.C.BusiGroupLabelKey) > 0 { bg := memsto.BusiGroupCache.GetByBusiGroupId(target.GroupId) if bg == nil { return @@ -29,7 +30,7 @@ func AppendLabels(pt *prompb.TimeSeries, target *models.Target) { } pt.Labels = append(pt.Labels, &prompb.Label{ - Name: "busigroup", + Name: config.C.BusiGroupLabelKey, Value: bg.LabelValue, }) } diff --git a/src/server/config/config.go b/src/server/config/config.go index 369914d4..c432774a 100644 --- a/src/server/config/config.go +++ b/src/server/config/config.go @@ -98,24 +98,25 @@ func MustLoad(fpaths ...string) { } type Config struct { - RunMode string - ClusterName string - EngineDelay int64 - Log logx.Config - HTTP httpx.Config - BasicAuth gin.Accounts - SMTP SMTPConfig - Heartbeat HeartbeatConfig - Alerting Alerting - NoData NoData - Redis storage.RedisConfig - Gorm storage.Gorm - MySQL storage.MySQL - Postgres storage.Postgres - WriterOpt writer.GlobalOpt - Writers []writer.Options - Reader reader.Options - Ibex Ibex + RunMode string + ClusterName string + BusiGroupLabelKey string + EngineDelay int64 + Log logx.Config + HTTP httpx.Config + BasicAuth gin.Accounts + SMTP SMTPConfig + Heartbeat HeartbeatConfig + Alerting Alerting + NoData NoData + Redis storage.RedisConfig + Gorm storage.Gorm + MySQL storage.MySQL + Postgres storage.Postgres + WriterOpt writer.GlobalOpt + Writers []writer.Options + Reader reader.Options + Ibex Ibex } type HeartbeatConfig struct {