models.go 833 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package alerting
  2. import "time"
  3. type AlertJob struct {
  4. Offset int64
  5. Delay bool
  6. Running bool
  7. RetryCount int
  8. Rule *AlertRule
  9. }
  10. func (aj *AlertJob) Retryable() bool {
  11. return aj.RetryCount < maxAlertExecutionRetries
  12. }
  13. func (aj *AlertJob) ResetRetry() {
  14. aj.RetryCount = 0
  15. }
  16. func (aj *AlertJob) IncRetry() {
  17. aj.RetryCount++
  18. }
  19. type AlertResult struct {
  20. State string
  21. TriggeredAlerts []*TriggeredAlert
  22. Error error
  23. Description string
  24. StartTime time.Time
  25. EndTime time.Time
  26. AlertJob *AlertJob
  27. }
  28. type TriggeredAlert struct {
  29. Value float64
  30. Metric string
  31. State string
  32. Tags map[string]string
  33. }
  34. type Level struct {
  35. Operator string
  36. Value float64
  37. }
  38. type AlertQuery struct {
  39. Query string
  40. DatasourceId int64
  41. From string
  42. To string
  43. }