alerting.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package dtos
  2. import (
  3. "time"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. type AlertRule struct {
  8. Id int64 `json:"id"`
  9. DashboardId int64 `json:"dashboardId"`
  10. PanelId int64 `json:"panelId"`
  11. Name string `json:"name"`
  12. Message string `json:"message"`
  13. State m.AlertStateType `json:"state"`
  14. Severity m.AlertSeverityType `json:"severity"`
  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. TimeMs string `json:"timeMs"`
  35. Error string `json:"error,omitempty"`
  36. EvalMatches []*EvalMatch `json:"matches,omitempty"`
  37. Logs []*AlertTestResultLog `json:"logs,omitempty"`
  38. }
  39. type AlertTestResultLog struct {
  40. Message string `json:"message"`
  41. Data interface{} `json:"data"`
  42. }
  43. type EvalMatch struct {
  44. Tags map[string]string `json:"tags,omitempty"`
  45. Metric string `json:"metric"`
  46. Value float64 `json:"value"`
  47. }
  48. type AlertHistory struct {
  49. AlertId int64 `json:"alertId"`
  50. NewState string `json:"newState"`
  51. Timestamp time.Time `json:"timestamp"`
  52. Title string `json:"title"`
  53. Text string `json:"text"`
  54. Metric string `json:"metric"`
  55. Data *simplejson.Json `json:"data"`
  56. }
  57. type NotificationTestCommand struct {
  58. Name string `json:"name"`
  59. Type string `json:"type"`
  60. Settings *simplejson.Json `json:"settings"`
  61. Severity string `json:"severity"`
  62. }