use metrics as hash key

This commit is contained in:
Ulric Qin 2022-06-17 09:56:10 +08:00
parent d0b005fb14
commit 7d326ef306
6 changed files with 19 additions and 22 deletions

View File

@ -2,7 +2,7 @@
NOW = $(shell date -u '+%Y%m%d%I%M%S') NOW = $(shell date -u '+%Y%m%d%I%M%S')
RELEASE_VERSION = 5.9.2 RELEASE_VERSION = 5.9.3
APP = n9e APP = n9e
SERVER_BIN = $(APP) SERVER_BIN = $(APP)

View File

@ -168,7 +168,7 @@ func pushMetrics() {
common.AppendLabels(pt, target) common.AppendLabels(pt, target)
} }
writer.Writers.PushSample("default_ident_target_up", pt) writer.Writers.PushSample("target_up", pt)
} }
// 把actives传给TargetCache看看除了active的部分还有别的target么有的话返回设置target_up = 0 // 把actives传给TargetCache看看除了active的部分还有别的target么有的话返回设置target_up = 0
@ -193,6 +193,6 @@ func pushMetrics() {
}) })
common.AppendLabels(pt, dead) common.AppendLabels(pt, dead)
writer.Writers.PushSample("default_ident_target_up", pt) writer.Writers.PushSample("target_up", pt)
} }
} }

View File

@ -261,12 +261,10 @@ func datadogSeries(c *gin.Context) {
if has { if has {
common.AppendLabels(pt, target) common.AppendLabels(pt, target)
} }
writer.Writers.PushSample(ident, pt)
} else {
writer.Writers.PushSample("default_hash_string", pt)
} }
writer.Writers.PushSample(item.Metric, pt)
succ++ succ++
} }

View File

@ -206,12 +206,10 @@ func falconPush(c *gin.Context) {
if has { if has {
common.AppendLabels(pt, target) common.AppendLabels(pt, target)
} }
writer.Writers.PushSample(ident, pt)
} else {
writer.Writers.PushSample("default_hash_string", pt)
} }
writer.Writers.PushSample(arr[i].Metric, pt)
succ++ succ++
} }

View File

@ -190,12 +190,10 @@ func handleOpenTSDB(c *gin.Context) {
if has { if has {
common.AppendLabels(pt, target) common.AppendLabels(pt, target)
} }
writer.Writers.PushSample(host, pt)
} else {
writer.Writers.PushSample("default_hash_string", pt)
} }
writer.Writers.PushSample(arr[i].Metric, pt)
succ++ succ++
} }

View File

@ -62,6 +62,7 @@ func remoteWrite(c *gin.Context) {
now = time.Now().Unix() now = time.Now().Unix()
ids = make(map[string]interface{}) ids = make(map[string]interface{})
ident string ident string
metric string
) )
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
@ -72,6 +73,10 @@ func remoteWrite(c *gin.Context) {
if req.Timeseries[i].Labels[j].Name == "ident" { if req.Timeseries[i].Labels[j].Name == "ident" {
ident = req.Timeseries[i].Labels[j].Value ident = req.Timeseries[i].Labels[j].Value
} }
if req.Timeseries[i].Labels[j].Name == "__name__" {
metric = req.Timeseries[i].Labels[j].Value
}
} }
if ident == "" { if ident == "" {
@ -94,11 +99,9 @@ func remoteWrite(c *gin.Context) {
if has { if has {
common.AppendLabels(req.Timeseries[i], target) common.AppendLabels(req.Timeseries[i], target)
} }
writer.Writers.PushSample(ident, req.Timeseries[i])
} else {
writer.Writers.PushSample("default_hash_string", req.Timeseries[i])
} }
writer.Writers.PushSample(metric, req.Timeseries[i])
} }
promstat.CounterSampleTotal.WithLabelValues(config.C.ClusterName, "prometheus").Add(float64(count)) promstat.CounterSampleTotal.WithLabelValues(config.C.ClusterName, "prometheus").Add(float64(count))