mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 01:42:12 +08:00
Alerting: added possibility to preview grafana managed alert rules. (#34600)
* starting to add eval logic. * wip * first version of test rule. * reverted file. * add info colum to result to show error or (with CC evalmatches) * fix labels in evalmatch * fix be test * refactored using observables. * moved widht/height div to outside panel rendere. * adding docs api level. * adding container styles to error div. * increasing size of preview. Co-authored-by: kyle <kyle@grafana.com>
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/expr/mathexp"
|
||||
"github.com/stretchr/testify/require"
|
||||
ptr "github.com/xorcare/pointer"
|
||||
@ -408,6 +409,17 @@ func valBasedSeries(vals ...*float64) mathexp.Series {
|
||||
return newSeries
|
||||
}
|
||||
|
||||
func valBasedSeriesWithLabels(l data.Labels, vals ...*float64) mathexp.Series {
|
||||
newSeries := mathexp.NewSeries("", l, 0, false, 1, true, len(vals))
|
||||
for idx, f := range vals {
|
||||
err := newSeries.SetPoint(idx, unixTimePointer(int64(idx)), f)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return newSeries
|
||||
}
|
||||
|
||||
func unixTimePointer(sec int64) *time.Time {
|
||||
t := time.Unix(sec, 0)
|
||||
return &t
|
||||
|
Reference in New Issue
Block a user