alerts.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. Interval string `json:"interval"`
  18. Frequency int64 `json:"frequency"`
  19. Title string `json:"title"`
  20. Description string `json:"description"`
  21. QueryRange int `json:"queryRange"`
  22. Aggregator string `json:"aggregator"`
  23. State string `json:"state"`
  24. Created time.Time `json:"created"`
  25. Updated time.Time `json:"updated"`
  26. }
  27. type AlertingClusterInfo struct {
  28. ServerId string
  29. ClusterSize int
  30. UptimePosition int
  31. }
  32. type HeartBeatCommand struct {
  33. ServerId string
  34. Result AlertingClusterInfo
  35. }
  36. type AlertRuleChange struct {
  37. Id int64 `json:"id"`
  38. OrgId int64 `json:"-"`
  39. AlertId int64 `json:"alertId"`
  40. Type string `json:"type"`
  41. Created time.Time `json:"created"`
  42. }
  43. // Commands
  44. type SaveAlertsCommand struct {
  45. DashboardId int64
  46. UserId int64
  47. OrgId int64
  48. Alerts []AlertRule
  49. }
  50. type DeleteAlertCommand struct {
  51. AlertId int64
  52. }
  53. //Queries
  54. type GetAlertsQuery struct {
  55. OrgId int64
  56. State []string
  57. DashboardId int64
  58. PanelId int64
  59. Result []AlertRule
  60. }
  61. type GetAlertsForExecutionQuery struct {
  62. Timestamp int64
  63. Result []AlertRule
  64. }
  65. type GetAlertByIdQuery struct {
  66. Id int64
  67. Result AlertRule
  68. }
  69. type GetAlertChangesQuery struct {
  70. OrgId int64
  71. Limit int64
  72. SinceId int64
  73. Result []AlertRuleChange
  74. }