support grafana-agent
This commit is contained in:
parent
8eb4a39e7d
commit
49176ae240
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
|||
|
||||
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
||||
|
||||
RELEASE_VERSION = 5.1.0
|
||||
RELEASE_VERSION = 5.2.0
|
||||
|
||||
APP = n9e
|
||||
SERVER_BIN = $(APP)
|
||||
|
|
|
@ -16,7 +16,7 @@ Nightingale, Prometheus enterprise edition
|
|||
- [x] notify.py support feishu
|
||||
- [ ] notify.py support sms
|
||||
- [ ] notify.py support voice
|
||||
- [ ] support remote write api
|
||||
- [x] support remote write api
|
||||
- [ ] support pushgateway api
|
||||
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ func handleOpenTSDB(c *gin.Context) {
|
|||
if len(list) > 0 {
|
||||
promstat.CounterSampleTotal.WithLabelValues(config.C.ClusterName, "opentsdb").Add(float64(len(list)))
|
||||
if !writer.Writers.PushQueue(list) {
|
||||
msg = "wirter queue full"
|
||||
msg = "writer queue full"
|
||||
}
|
||||
|
||||
idents.Idents.MSet(ids)
|
||||
|
|
|
@ -58,18 +58,30 @@ func remoteWrite(c *gin.Context) {
|
|||
}
|
||||
|
||||
var (
|
||||
now = time.Now().Unix()
|
||||
ids = make(map[string]interface{})
|
||||
lst = make([]interface{}, count)
|
||||
now = time.Now().Unix()
|
||||
ids = make(map[string]interface{})
|
||||
lst = make([]interface{}, count)
|
||||
ident string
|
||||
)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
labels := req.Timeseries[i].GetLabels()
|
||||
ident = ""
|
||||
|
||||
ident := ""
|
||||
for _, label := range labels {
|
||||
if label.GetName() == "ident" {
|
||||
ident = label.GetValue()
|
||||
// find ident label
|
||||
for j := 0; j < len(req.Timeseries[i].Labels); j++ {
|
||||
if req.Timeseries[i].Labels[j].Name == "ident" {
|
||||
ident = req.Timeseries[i].Labels[j].Value
|
||||
}
|
||||
}
|
||||
|
||||
if ident == "" {
|
||||
// not found, try agent_hostname
|
||||
for j := 0; j < len(req.Timeseries[i].Labels); j++ {
|
||||
// agent_hostname for grafana-agent
|
||||
if req.Timeseries[i].Labels[j].Name == "agent_hostname" {
|
||||
req.Timeseries[i].Labels[j].Name = "ident"
|
||||
ident = req.Timeseries[i].Labels[j].Value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +109,7 @@ func remoteWrite(c *gin.Context) {
|
|||
if writer.Writers.PushQueue(lst) {
|
||||
c.String(200, "")
|
||||
} else {
|
||||
c.String(http.StatusInternalServerError, "wirter queue full")
|
||||
c.String(http.StatusInternalServerError, "writer queue full")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue