fix: recovery alert value is null & refactor stats
This commit is contained in:
parent
5df96d41a7
commit
3092b4b65d
|
@ -110,16 +110,16 @@ func Judge(stra *model.Stra, exps []model.Exp, historyData []*dataobj.RRDData, f
|
|||
}()
|
||||
|
||||
leftValue, isTriggered = judgeItemWithStrategy(stra, historyData, exps[0], firstItem, now)
|
||||
if !isTriggered {
|
||||
return
|
||||
}
|
||||
|
||||
if value == "" {
|
||||
value = fmt.Sprintf("%s: %v", exp.Metric, leftValue)
|
||||
} else {
|
||||
value += fmt.Sprintf("; %s: %v", exp.Metric, leftValue)
|
||||
}
|
||||
|
||||
if !isTriggered {
|
||||
return
|
||||
}
|
||||
|
||||
//与条件情况下执行
|
||||
if len(exps) > 1 {
|
||||
if exps[1].Func == "nodata" { //nodata重新查询索引来进行告警判断
|
||||
|
|
|
@ -18,11 +18,12 @@ type IdentitySection struct {
|
|||
func Init(identity IdentitySection) {
|
||||
if identity.Specify != "" {
|
||||
Identity = identity.Specify
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
Identity, err = sys.CmdOutTrim("bash", "-c", identity.Shell)
|
||||
if err != nil {
|
||||
log.Fatalln("[F] cannot get hostname")
|
||||
log.Fatalln("[F] cannot get identity")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/didi/nightingale/src/dataobj"
|
||||
"github.com/didi/nightingale/src/toolkits/identity"
|
||||
|
||||
"github.com/toolkits/pkg/logger"
|
||||
)
|
||||
|
@ -42,7 +41,6 @@ func Push() {
|
|||
func NewMetricValue(metric string, value int64) *dataobj.MetricValue {
|
||||
item := &dataobj.MetricValue{
|
||||
Metric: metric,
|
||||
Endpoint: identity.Identity,
|
||||
Timestamp: time.Now().Unix(),
|
||||
ValueUntyped: value,
|
||||
CounterType: "GAUGE",
|
||||
|
|
Loading…
Reference in New Issue