Skip to content

Commit

Permalink
use metrics as hash key
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Jun 17, 2022
1 parent d0b005f commit 7d326ef
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/server/idents/idents.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -193,6 +193,6 @@ func pushMetrics() {
})

common.AppendLabels(pt, dead)
writer.Writers.PushSample("default_ident_target_up", pt)
writer.Writers.PushSample("target_up", pt)
}
}
6 changes: 2 additions & 4 deletions src/server/router/router_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}

Expand Down
6 changes: 2 additions & 4 deletions src/server/router/router_openfalcon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}

Expand Down
6 changes: 2 additions & 4 deletions src/server/router/router_opentsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}

Expand Down
17 changes: 10 additions & 7 deletions src/server/router/router_prom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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 == "" {
Expand All @@ -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))
Expand Down

0 comments on commit 7d326ef

Please sign in to comment.