提交 7d326ef3 编写于 作者: U Ulric Qin

use metrics as hash key

上级 d0b005fb
......@@ -2,7 +2,7 @@
NOW = $(shell date -u '+%Y%m%d%I%M%S')
RELEASE_VERSION = 5.9.2
RELEASE_VERSION = 5.9.3
APP = n9e
SERVER_BIN = $(APP)
......
......@@ -168,7 +168,7 @@ func pushMetrics() {
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
......@@ -193,6 +193,6 @@ func pushMetrics() {
})
common.AppendLabels(pt, dead)
writer.Writers.PushSample("default_ident_target_up", pt)
writer.Writers.PushSample("target_up", pt)
}
}
......@@ -261,12 +261,10 @@ func datadogSeries(c *gin.Context) {
if has {
common.AppendLabels(pt, target)
}
writer.Writers.PushSample(ident, pt)
} else {
writer.Writers.PushSample("default_hash_string", pt)
}
writer.Writers.PushSample(item.Metric, pt)
succ++
}
......
......@@ -206,12 +206,10 @@ func falconPush(c *gin.Context) {
if has {
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++
}
......
......@@ -190,12 +190,10 @@ func handleOpenTSDB(c *gin.Context) {
if has {
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++
}
......
......@@ -59,9 +59,10 @@ func remoteWrite(c *gin.Context) {
}
var (
now = time.Now().Unix()
ids = make(map[string]interface{})
ident string
now = time.Now().Unix()
ids = make(map[string]interface{})
ident string
metric string
)
for i := 0; i < count; i++ {
......@@ -72,6 +73,10 @@ func remoteWrite(c *gin.Context) {
if req.Timeseries[i].Labels[j].Name == "ident" {
ident = req.Timeseries[i].Labels[j].Value
}
if req.Timeseries[i].Labels[j].Name == "__name__" {
metric = req.Timeseries[i].Labels[j].Value
}
}
if ident == "" {
......@@ -94,11 +99,9 @@ func remoteWrite(c *gin.Context) {
if has {
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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册