alerting.go 1.9 KB

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