@@ -344,23 +344,28 @@ type Rules []interface{}
344
344
345
345
// AlertingRule models a alerting rule.
346
346
type AlertingRule struct {
347
- Name string `json:"name"`
348
- Query string `json:"query"`
349
- Duration float64 `json:"duration"`
350
- Labels model.LabelSet `json:"labels"`
351
- Annotations model.LabelSet `json:"annotations"`
352
- Alerts []* Alert `json:"alerts"`
353
- Health RuleHealth `json:"health"`
354
- LastError string `json:"lastError,omitempty"`
347
+ Name string `json:"name"`
348
+ Query string `json:"query"`
349
+ Duration float64 `json:"duration"`
350
+ Labels model.LabelSet `json:"labels"`
351
+ Annotations model.LabelSet `json:"annotations"`
352
+ Alerts []* Alert `json:"alerts"`
353
+ Health RuleHealth `json:"health"`
354
+ LastError string `json:"lastError,omitempty"`
355
+ EvaluationTime float64 `json:"evaluationTime"`
356
+ LastEvaluation time.Time `json:"lastEvaluation"`
357
+ State string `json:"state"`
355
358
}
356
359
357
360
// RecordingRule models a recording rule.
358
361
type RecordingRule struct {
359
- Name string `json:"name"`
360
- Query string `json:"query"`
361
- Labels model.LabelSet `json:"labels,omitempty"`
362
- Health RuleHealth `json:"health"`
363
- LastError string `json:"lastError,omitempty"`
362
+ Name string `json:"name"`
363
+ Query string `json:"query"`
364
+ Labels model.LabelSet `json:"labels,omitempty"`
365
+ Health RuleHealth `json:"health"`
366
+ LastError string `json:"lastError,omitempty"`
367
+ EvaluationTime float64 `json:"evaluationTime"`
368
+ LastEvaluation time.Time `json:"lastEvaluation"`
364
369
}
365
370
366
371
// Alert models an active alert.
@@ -480,14 +485,17 @@ func (r *AlertingRule) UnmarshalJSON(b []byte) error {
480
485
}
481
486
482
487
rule := struct {
483
- Name string `json:"name"`
484
- Query string `json:"query"`
485
- Duration float64 `json:"duration"`
486
- Labels model.LabelSet `json:"labels"`
487
- Annotations model.LabelSet `json:"annotations"`
488
- Alerts []* Alert `json:"alerts"`
489
- Health RuleHealth `json:"health"`
490
- LastError string `json:"lastError,omitempty"`
488
+ Name string `json:"name"`
489
+ Query string `json:"query"`
490
+ Duration float64 `json:"duration"`
491
+ Labels model.LabelSet `json:"labels"`
492
+ Annotations model.LabelSet `json:"annotations"`
493
+ Alerts []* Alert `json:"alerts"`
494
+ Health RuleHealth `json:"health"`
495
+ LastError string `json:"lastError,omitempty"`
496
+ EvaluationTime float64 `json:"evaluationTime"`
497
+ LastEvaluation time.Time `json:"lastEvaluation"`
498
+ State string `json:"state"`
491
499
}{}
492
500
if err := json .Unmarshal (b , & rule ); err != nil {
493
501
return err
@@ -500,6 +508,9 @@ func (r *AlertingRule) UnmarshalJSON(b []byte) error {
500
508
r .Duration = rule .Duration
501
509
r .Labels = rule .Labels
502
510
r .LastError = rule .LastError
511
+ r .EvaluationTime = rule .EvaluationTime
512
+ r .LastEvaluation = rule .LastEvaluation
513
+ r .State = rule .State
503
514
504
515
return nil
505
516
}
@@ -519,11 +530,13 @@ func (r *RecordingRule) UnmarshalJSON(b []byte) error {
519
530
}
520
531
521
532
rule := struct {
522
- Name string `json:"name"`
523
- Query string `json:"query"`
524
- Labels model.LabelSet `json:"labels,omitempty"`
525
- Health RuleHealth `json:"health"`
526
- LastError string `json:"lastError,omitempty"`
533
+ Name string `json:"name"`
534
+ Query string `json:"query"`
535
+ Labels model.LabelSet `json:"labels,omitempty"`
536
+ Health RuleHealth `json:"health"`
537
+ LastError string `json:"lastError,omitempty"`
538
+ EvaluationTime float64 `json:"evaluationTime"`
539
+ LastEvaluation time.Time `json:"lastEvaluation"`
527
540
}{}
528
541
if err := json .Unmarshal (b , & rule ); err != nil {
529
542
return err
@@ -533,6 +546,8 @@ func (r *RecordingRule) UnmarshalJSON(b []byte) error {
533
546
r .Name = rule .Name
534
547
r .LastError = rule .LastError
535
548
r .Query = rule .Query
549
+ r .EvaluationTime = rule .EvaluationTime
550
+ r .LastEvaluation = rule .LastEvaluation
536
551
537
552
return nil
538
553
}
0 commit comments