alerts.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package models
  2. import (
  3. "time"
  4. )
  5. type AlertRule struct {
  6. Id int64 `json:"id"`
  7. OrgId int64 `json:"-"`
  8. DatasourceId int64 `json:"datasourceId"`
  9. DashboardId int64 `json:"dashboardId"`
  10. PanelId int64 `json:"panelId"`
  11. Query string `json:"query"`
  12. QueryRefId string `json:"queryRefId"`
  13. WarnLevel int64 `json:"warnLevel"`
  14. CritLevel int64 `json:"critLevel"`
  15. WarnOperator string `json:"warnOperator"`
  16. CritOperator string `json:"critOperator"`
  17. Frequency int64 `json:"frequency"`
  18. Title string `json:"title"`
  19. Description string `json:"description"`
  20. QueryRange int `json:"queryRange"`
  21. Aggregator string `json:"aggregator"`
  22. State string `json:"state"`
  23. Created time.Time `json:"created"`
  24. Updated time.Time `json:"updated"`
  25. }
  26. type AlertingClusterInfo struct {
  27. ServerId string
  28. ClusterSize int
  29. UptimePosition int
  30. }
  31. type HeartBeatCommand struct {
  32. ServerId string
  33. Result AlertingClusterInfo
  34. }
  35. type AlertRuleChange struct {
  36. Id int64 `json:"id"`
  37. OrgId int64 `json:"-"`
  38. AlertId int64 `json:"alertId"`
  39. Type string `json:"type"`
  40. Created time.Time `json:"created"`
  41. }
  42. // Commands
  43. type SaveAlertsCommand struct {
  44. DashboardId int64
  45. UserId int64
  46. OrgId int64
  47. Alerts []AlertRule
  48. }
  49. type DeleteAlertCommand struct {
  50. AlertId int64
  51. }
  52. //Queries
  53. type GetAlertsQuery struct {
  54. OrgId int64
  55. State []string
  56. DashboardId int64
  57. PanelId int64
  58. Result []AlertRule
  59. }
  60. type GetAlertsForExecutionQuery struct {
  61. Timestamp int64
  62. Result []AlertRule
  63. }
  64. type GetAlertByIdQuery struct {
  65. Id int64
  66. Result AlertRule
  67. }
  68. type GetAlertChangesQuery struct {
  69. OrgId int64
  70. Limit int64
  71. SinceId int64
  72. Result []AlertRuleChange
  73. }