alert_rule_reader.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package alerting
  2. import (
  3. "github.com/grafana/grafana/pkg/bus"
  4. m "github.com/grafana/grafana/pkg/models"
  5. )
  6. type RuleReader interface {
  7. Fetch() []m.AlertRule
  8. }
  9. type AlertRuleReader struct{}
  10. func (this AlertRuleReader) Fetch() []m.AlertRule {
  11. /*
  12. return []m.AlertRule{
  13. //{Id: 1, Title: "alert rule 1", Interval: "10s", Frequency: 10},
  14. //{Id: 2, Title: "alert rule 2", Interval: "10s", Frequency: 10},
  15. //{Id: 3, Title: "alert rule 3", Interval: "10s", Frequency: 10},
  16. //{Id: 4, Title: "alert rule 4", Interval: "10s", Frequency: 5},
  17. //{Id: 5, Title: "alert rule 5", Interval: "10s", Frequency: 5},
  18. {
  19. Id: 1,
  20. OrgId: 1,
  21. Title: "alert rule 1",
  22. Frequency: 3,
  23. DatasourceId: 1,
  24. WarnOperator: "<",
  25. WarnLevel: 3,
  26. CritOperator: "<",
  27. CritLevel: 4,
  28. Aggregator: "avg",
  29. Query: `{"refId":"A","target":"statsd.fakesite.counters.session_start.*.count","textEditor":true}"`,
  30. QueryRange: 3600,
  31. },
  32. }
  33. */
  34. cmd := &m.GetAlertsQuery{
  35. OrgId: 1,
  36. }
  37. bus.Dispatch(cmd)
  38. return cmd.Result
  39. }