bugfix: aggr output and alert

This commit is contained in:
710leo 2021-05-27 00:46:21 +08:00
parent 22f0aee55d
commit a73f2654df
3 changed files with 27 additions and 11 deletions

View File

@ -393,13 +393,16 @@ func Parse(ymlFile string) error {
}
fmt.Println("config.file:", ymlFile)
Ident, _ = identity.GetIdent()
if err := parseOps(); err != nil {
return err
}
return identity.Parse()
if err := identity.Parse(); err != nil {
return err
}
Ident, _ = identity.GetIdent()
return nil
}
// map["node"]="host1,host2" --> map["node"]=["host1", "host2"]

View File

@ -410,13 +410,6 @@ func eventCurClaim(c *gin.Context) {
var f claimForm
errors.Dangerous(c.ShouldBind(&f))
eventCur := mustEventCur(f.Id)
can, err := models.UsernameCandoNodeOp(username, "mon_event_write", eventCur.Nid)
errors.Dangerous(err)
if !can {
errors.Bomb(_s("no privilege"))
}
id := f.Id
nodePath := f.NodePath
@ -429,9 +422,28 @@ func eventCurClaim(c *gin.Context) {
}
if id != 0 {
eventCur := mustEventCur(id)
can, err := models.UsernameCandoNodeOp(username, "mon_event_write", eventCur.Nid)
errors.Dangerous(err)
if !can {
errors.Bomb(_s("no privilege"))
}
renderMessage(c, models.UpdateClaimantsById(users[0].Id, id))
return
}
node, err := models.NodeGet("path=?", nodePath)
errors.Dangerous(err)
if node == nil {
errors.Bomb(_s("node not found"))
}
can, err := models.UsernameCandoNodeOp(username, "mon_event_write", node.Id)
errors.Dangerous(err)
if !can {
errors.Bomb(_s("no privilege"))
}
renderMessage(c, models.UpdateClaimantsByNodePath(users[0].Id, nodePath))
}

View File

@ -5,6 +5,7 @@ import (
"log"
"os"
"os/signal"
"strings"
"github.com/didi/nightingale/v4/src/common/dataobj"
"github.com/didi/nightingale/v4/src/common/stats"
@ -95,7 +96,7 @@ func aggrOut2MetricValue(out *dataobj.AggrOut) *dataobj.MetricValue {
Metric: cache.AggrCalcMap.GetMetric(out.Data.Sid),
Timestamp: out.Data.Timestamp / 1000,
Step: out.Data.Step,
Tags: out.Data.GroupTag,
Tags: strings.Replace(out.Data.GroupTag, "||", ",", -1),
ValueUntyped: out.Data.Value,
CounterType: "GAUGE",
}