alerting.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package dtos
  2. import (
  3. "time"
  4. "github.com/grafana/grafana/pkg/components/null"
  5. "github.com/grafana/grafana/pkg/components/simplejson"
  6. m "github.com/grafana/grafana/pkg/models"
  7. )
  8. type AlertRule struct {
  9. Id int64 `json:"id"`
  10. DashboardId int64 `json:"dashboardId"`
  11. PanelId int64 `json:"panelId"`
  12. Name string `json:"name"`
  13. Message string `json:"message"`
  14. State m.AlertStateType `json:"state"`
  15. NewStateDate time.Time `json:"newStateDate"`
  16. EvalDate time.Time `json:"evalDate"`
  17. EvalData *simplejson.Json `json:"evalData"`
  18. ExecutionError string `json:"executionError"`
  19. Url string `json:"url"`
  20. CanEdit bool `json:"canEdit"`
  21. }
  22. type AlertNotification struct {
  23. Id int64 `json:"id"`
  24. Name string `json:"name"`
  25. Type string `json:"type"`
  26. IsDefault bool `json:"isDefault"`
  27. NotifyOnce bool `json:"notifyOnce"`
  28. Frequency string `json:"frequency"`
  29. Created time.Time `json:"created"`
  30. Updated time.Time `json:"updated"`
  31. Settings *simplejson.Json `json:"settings"`
  32. }
  33. type AlertTestCommand struct {
  34. Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
  35. PanelId int64 `json:"panelId" binding:"Required"`
  36. }
  37. type AlertTestResult struct {
  38. Firing bool `json:"firing"`
  39. State m.AlertStateType `json:"state"`
  40. ConditionEvals string `json:"conditionEvals"`
  41. TimeMs string `json:"timeMs"`
  42. Error string `json:"error,omitempty"`
  43. EvalMatches []*EvalMatch `json:"matches,omitempty"`
  44. Logs []*AlertTestResultLog `json:"logs,omitempty"`
  45. }
  46. type AlertTestResultLog struct {
  47. Message string `json:"message"`
  48. Data interface{} `json:"data"`
  49. }
  50. type EvalMatch struct {
  51. Tags map[string]string `json:"tags,omitempty"`
  52. Metric string `json:"metric"`
  53. Value null.Float `json:"value"`
  54. }
  55. type NotificationTestCommand struct {
  56. Name string `json:"name"`
  57. Type string `json:"type"`
  58. NotifyOnce bool `json:"notifyOnce"`
  59. Frequency string `json:"frequency"`
  60. Settings *simplejson.Json `json:"settings"`
  61. }
  62. type PauseAlertCommand struct {
  63. AlertId int64 `json:"alertId"`
  64. Paused bool `json:"paused"`
  65. }
  66. type PauseAllAlertsCommand struct {
  67. Paused bool `json:"paused"`
  68. }