alerting.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. DashbboardUri string `json:"dashboardUri"`
  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. Created time.Time `json:"created"`
  28. Updated time.Time `json:"updated"`
  29. }
  30. type AlertTestCommand struct {
  31. Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
  32. PanelId int64 `json:"panelId" binding:"Required"`
  33. }
  34. type AlertTestResult struct {
  35. Firing bool `json:"firing"`
  36. State m.AlertStateType `json:"state"`
  37. ConditionEvals string `json:"conditionEvals"`
  38. TimeMs string `json:"timeMs"`
  39. Error string `json:"error,omitempty"`
  40. EvalMatches []*EvalMatch `json:"matches,omitempty"`
  41. Logs []*AlertTestResultLog `json:"logs,omitempty"`
  42. }
  43. type AlertTestResultLog struct {
  44. Message string `json:"message"`
  45. Data interface{} `json:"data"`
  46. }
  47. type EvalMatch struct {
  48. Tags map[string]string `json:"tags,omitempty"`
  49. Metric string `json:"metric"`
  50. Value null.Float `json:"value"`
  51. }
  52. type NotificationTestCommand struct {
  53. Name string `json:"name"`
  54. Type string `json:"type"`
  55. Settings *simplejson.Json `json:"settings"`
  56. }
  57. type PauseAlertCommand struct {
  58. AlertId int64 `json:"alertId"`
  59. Paused bool `json:"paused"`
  60. }
  61. type PauseAllAlertsCommand struct {
  62. Paused bool `json:"paused"`
  63. }