// updateWith performs modification of current Rule
// with fields of the given Rule.
updateWith(Rule)error
// close performs the shutdown procedures for rule
// such as metrics unregister
close()
}
varerrDuplicate=errors.New("result contains metrics with the same labelset after applying rule labels. See https://docs.victoriametrics.com/vmalert.html#series-with-the-same-labelset for details")
typeruleStatestruct{
sync.RWMutex
entries[]StateEntry
curint
}
// StateEntry stores rule's execution states
typeStateEntrystruct{
// stores last moment of time rule.Exec was called
Timetime.Time
// stores the timesteamp with which rule.Exec was called
Attime.Time
// stores the duration of the last rule.Exec call
Durationtime.Duration
// stores last error that happened in Exec func
// resets on every successful Exec
// may be used as Health ruleState
Errerror
// stores the number of samples returned during
// the last evaluation
Samplesint
// stores the number of time series fetched during
// the last evaluation.
// Is supported by VictoriaMetrics only, starting from v1.90.0
// If seriesFetched == nil, then this attribute was missing in
// datasource response (unsupported).
SeriesFetched*int
// stores the curl command reflecting the HTTP request used during rule.Exec
Curlstring
}
// GetLastEntry returns latest stateEntry of rule
funcGetLastEntry(rRule)StateEntry{
ifrule,ok:=r.(*AlertingRule);ok{
returnrule.state.getLast()
}
ifrule,ok:=r.(*RecordingRule);ok{
returnrule.state.getLast()
}
returnStateEntry{}
}
// GetRuleStateSize returns size of rule stateEntry