mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-23 12:44:05 -08:00
web/api/v1: make names consistent. (#7841)
Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
parent
442b3364d7
commit
2f2a51a43a
|
@ -237,8 +237,8 @@ type Group struct {
|
|||
staleSeries []labels.Labels
|
||||
opts *ManagerOptions
|
||||
mtx sync.Mutex
|
||||
evaluationDuration time.Duration
|
||||
evaluationTimestamp time.Time
|
||||
evaluationTime time.Duration
|
||||
lastEvaluation time.Time
|
||||
|
||||
shouldRestore bool
|
||||
|
||||
|
@ -332,8 +332,8 @@ func (g *Group) run(ctx context.Context) {
|
|||
timeSinceStart := time.Since(start)
|
||||
|
||||
g.metrics.iterationDuration.Observe(timeSinceStart.Seconds())
|
||||
g.setEvaluationDuration(timeSinceStart)
|
||||
g.setEvaluationTimestamp(start)
|
||||
g.setEvaluationTime(timeSinceStart)
|
||||
g.setLastEvaluation(start)
|
||||
}
|
||||
|
||||
// The assumption here is that since the ticker was started after having
|
||||
|
@ -454,36 +454,36 @@ func (g *Group) HasAlertingRules() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// GetEvaluationDuration returns the time in seconds it took to evaluate the rule group.
|
||||
func (g *Group) GetEvaluationDuration() time.Duration {
|
||||
// GetEvaluationTime returns the time in seconds it took to evaluate the rule group.
|
||||
func (g *Group) GetEvaluationTime() time.Duration {
|
||||
g.mtx.Lock()
|
||||
defer g.mtx.Unlock()
|
||||
return g.evaluationDuration
|
||||
return g.evaluationTime
|
||||
}
|
||||
|
||||
// setEvaluationDuration sets the time in seconds the last evaluation took.
|
||||
func (g *Group) setEvaluationDuration(dur time.Duration) {
|
||||
// setEvaluationTime sets the time in seconds the last evaluation took.
|
||||
func (g *Group) setEvaluationTime(dur time.Duration) {
|
||||
g.metrics.groupLastDuration.WithLabelValues(groupKey(g.file, g.name)).Set(dur.Seconds())
|
||||
|
||||
g.mtx.Lock()
|
||||
defer g.mtx.Unlock()
|
||||
g.evaluationDuration = dur
|
||||
g.evaluationTime = dur
|
||||
}
|
||||
|
||||
// GetEvaluationTimestamp returns the time the last evaluation of the rule group took place.
|
||||
func (g *Group) GetEvaluationTimestamp() time.Time {
|
||||
// GetLastEvaluation returns the time the last evaluation of the rule group took place.
|
||||
func (g *Group) GetLastEvaluation() time.Time {
|
||||
g.mtx.Lock()
|
||||
defer g.mtx.Unlock()
|
||||
return g.evaluationTimestamp
|
||||
return g.lastEvaluation
|
||||
}
|
||||
|
||||
// setEvaluationTimestamp updates evaluationTimestamp to the timestamp of when the rule group was last evaluated.
|
||||
func (g *Group) setEvaluationTimestamp(ts time.Time) {
|
||||
// setLastEvaluation updates lastEvaluation to the timestamp of when the rule group was last evaluated.
|
||||
func (g *Group) setLastEvaluation(ts time.Time) {
|
||||
g.metrics.groupLastEvalTime.WithLabelValues(groupKey(g.file, g.name)).Set(float64(ts.UnixNano()) / 1e9)
|
||||
|
||||
g.mtx.Lock()
|
||||
defer g.mtx.Unlock()
|
||||
g.evaluationTimestamp = ts
|
||||
g.lastEvaluation = ts
|
||||
}
|
||||
|
||||
// evalTimestamp returns the immediately preceding consistently slotted evaluation time.
|
||||
|
@ -507,8 +507,8 @@ func nameAndLabels(rule Rule) string {
|
|||
// Rules are matched based on their name and labels. If there are duplicates, the
|
||||
// first is matched with the first, second with the second etc.
|
||||
func (g *Group) CopyState(from *Group) {
|
||||
g.evaluationDuration = from.evaluationDuration
|
||||
g.evaluationTimestamp = from.evaluationTimestamp
|
||||
g.evaluationTime = from.evaluationTime
|
||||
g.lastEvaluation = from.lastEvaluation
|
||||
|
||||
ruleMap := make(map[string][]int, len(from.rules))
|
||||
|
||||
|
|
|
@ -626,7 +626,7 @@ func TestCopyState(t *testing.T) {
|
|||
{"r3c": labels.Labels{{Name: "l1", Value: "v3"}}},
|
||||
{"a2": labels.Labels{{Name: "l2", Value: "v1"}}},
|
||||
},
|
||||
evaluationDuration: time.Second,
|
||||
evaluationTime: time.Second,
|
||||
}
|
||||
oldGroup.rules[0].(*AlertingRule).active[42] = nil
|
||||
newGroup := &Group{
|
||||
|
@ -656,8 +656,8 @@ func TestCopyState(t *testing.T) {
|
|||
}
|
||||
testutil.Equals(t, want, newGroup.seriesInPreviousEval)
|
||||
testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3])
|
||||
testutil.Equals(t, oldGroup.evaluationDuration, newGroup.evaluationDuration)
|
||||
testutil.Equals(t, oldGroup.evaluationTimestamp, newGroup.evaluationTimestamp)
|
||||
testutil.Equals(t, oldGroup.evaluationTime, newGroup.evaluationTime)
|
||||
testutil.Equals(t, oldGroup.lastEvaluation, newGroup.lastEvaluation)
|
||||
testutil.Equals(t, []labels.Labels{{{Name: "l1", Value: "v3"}}}, newGroup.staleSeries)
|
||||
}
|
||||
|
||||
|
|
|
@ -1063,8 +1063,8 @@ func (api *API) rules(r *http.Request) apiFuncResult {
|
|||
File: grp.File(),
|
||||
Interval: grp.Interval().Seconds(),
|
||||
Rules: []rule{},
|
||||
EvaluationTime: grp.GetEvaluationDuration().Seconds(),
|
||||
LastEvaluation: grp.GetEvaluationTimestamp(),
|
||||
EvaluationTime: grp.GetEvaluationTime().Seconds(),
|
||||
LastEvaluation: grp.GetLastEvaluation(),
|
||||
}
|
||||
for _, r := range grp.Rules() {
|
||||
var enrichedRule rule
|
||||
|
|
Loading…
Reference in a new issue