feat(alerting): began work on testing alert rule from UI without having to save it
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/alerting"
|
||||
)
|
||||
|
||||
func ValidateOrgAlert(c *middleware.Context) {
|
||||
@@ -71,6 +72,21 @@ func GetAlerts(c *middleware.Context) Response {
|
||||
return Json(200, alertDTOs)
|
||||
}
|
||||
|
||||
// POST /api/alerts/test
|
||||
func TestAlertRule(c *middleware.Context, dto dtos.TestAlertRuleCommand) Response {
|
||||
backendCmd := alerting.TestAlertRuleCommand{
|
||||
OrgId: c.OrgId,
|
||||
Dashboard: dto.Dashboard,
|
||||
PanelId: dto.PanelId,
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&backendCmd); err != nil {
|
||||
return ApiError(500, "Failed to test rule", err)
|
||||
}
|
||||
|
||||
return Json(200, backendCmd.Result)
|
||||
}
|
||||
|
||||
// GET /api/alerts/:id
|
||||
func GetAlert(c *middleware.Context) Response {
|
||||
id := c.ParamsInt64(":alertId")
|
||||
|
||||
Reference in New Issue
Block a user