mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Always use cache: stop passing skipCache among ngalert functions * Add updated column * Scheduler initial draft * Add retry on failure * Allow settting/updating alert definition interval Set default interval if no interval is provided during alert definition creation. Keep existing alert definition interval if no interval is provided during alert definition update. * Parameterise alerting.Ticker to run on custom interval * Allow updating alert definition interval without having to provide the queries and expressions * Add schedule tests * Use xorm tags for having initialisms with consistent case in Go * Add ability to pause/unpause the scheduler * Add alert definition versioning * Optimise scheduler to fetch alert definition only when it's necessary * Change MySQL data column to mediumtext * Delete alert definition versions * Increase default scheduler interval to 10 seconds * Fix setting OrgID on updates * Add validation for alert definition name length * Recreate tables
21 lines
485 B
Go
21 lines
485 B
Go
package ngalert
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
func (ng *AlertNG) validateOrgAlertDefinition(c *models.ReqContext) {
|
|
id := c.ParamsInt64(":alertDefinitionId")
|
|
query := getAlertDefinitionByIDQuery{ID: id}
|
|
|
|
if err := ng.getAlertDefinitionByID(&query); err != nil {
|
|
c.JsonApiErr(404, "Alert definition not found", nil)
|
|
return
|
|
}
|
|
|
|
if c.OrgId != query.Result.OrgID {
|
|
c.JsonApiErr(403, "You are not allowed to edit/view alert definition", nil)
|
|
return
|
|
}
|
|
}
|