alerting.go 2.2 KB

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