alerting.go 2.1 KB

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