mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 19:00:54 -06:00
2c90dcf3c0
* Create DashAlertService service * Remove no used dashboard service from plugin's manager that generates dependency cycle in Enterprise * Remove bus for dashboard permissions * Remove bus from dashboard extractor service * Add missing argument * Fix wire * Fix lint * More goimports * Use datasource service instead sql calls * Fix integration test
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package alerting
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/grafana/grafana/pkg/components/null"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
// Job holds state about when the alert rule should be evaluated.
|
|
type Job struct {
|
|
Offset int64
|
|
OffsetWait bool
|
|
Delay bool
|
|
running bool
|
|
Rule *Rule
|
|
runningLock sync.Mutex // Lock for running property which is used in the Scheduler and AlertEngine execution
|
|
}
|
|
|
|
// GetRunning returns true if the job is running. A lock is taken and released on the Job to ensure atomicity.
|
|
func (j *Job) GetRunning() bool {
|
|
defer j.runningLock.Unlock()
|
|
j.runningLock.Lock()
|
|
return j.running
|
|
}
|
|
|
|
// SetRunning sets the running property on the Job. A lock is taken and released on the Job to ensure atomicity.
|
|
func (j *Job) SetRunning(b bool) {
|
|
j.runningLock.Lock()
|
|
j.running = b
|
|
j.runningLock.Unlock()
|
|
}
|
|
|
|
// ResultLogEntry represents log data for the alert evaluation.
|
|
type ResultLogEntry struct {
|
|
Message string
|
|
Data interface{}
|
|
}
|
|
|
|
// EvalMatch represents the series violating the threshold.
|
|
type EvalMatch struct {
|
|
Value null.Float `json:"value"`
|
|
Metric string `json:"metric"`
|
|
Tags map[string]string `json:"tags"`
|
|
}
|
|
|
|
type DashAlertInfo struct {
|
|
User *models.SignedInUser
|
|
Dash *models.Dashboard
|
|
OrgID int64
|
|
}
|