mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tech(alerting): change queryrange to int from str
This commit is contained in:
parent
51511dd654
commit
16a9e56eca
@ -13,7 +13,7 @@ type AlertRuleDTO struct {
|
||||
Interval string `json:"interval"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
QueryRange string `json:"queryRange"`
|
||||
QueryRange int `json:"queryRange"`
|
||||
Aggregator string `json:"aggregator"`
|
||||
State string `json:"state"`
|
||||
|
||||
|
@ -20,7 +20,7 @@ type AlertRule struct {
|
||||
Frequency int64 `json:"frequency"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
QueryRange string `json:"queryRange"`
|
||||
QueryRange int `json:"queryRange"`
|
||||
Aggregator string `json:"aggregator"`
|
||||
State string `json:"state"`
|
||||
|
||||
|
@ -30,7 +30,7 @@ func (this AlertRuleReader) Fetch() []m.AlertRule {
|
||||
CritLevel: 4,
|
||||
Aggregator: "avg",
|
||||
Query: `{"refId":"A","target":"statsd.fakesite.counters.session_start.*.count","textEditor":true}"`,
|
||||
QueryRange: "1h",
|
||||
QueryRange: 3600,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func ParseAlertsFromDashboard(cmd *m.SaveDashboardCommand) []m.AlertRule {
|
||||
Interval: alerting.Get("interval").MustString(),
|
||||
Title: alerting.Get("title").MustString(),
|
||||
Description: alerting.Get("description").MustString(),
|
||||
QueryRange: alerting.Get("queryRange").MustString(),
|
||||
QueryRange: alerting.Get("queryRange").MustInt(),
|
||||
Aggregator: alerting.Get("aggregator").MustString(),
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -30,7 +31,7 @@ func (this GraphiteClient) GetSeries(rule m.AlertRule) (m.TimeSeriesSlice, error
|
||||
"format": []string{"json"},
|
||||
"target": []string{getTargetFromRule(rule)},
|
||||
"until": []string{"now"},
|
||||
"from": []string{"-" + rule.QueryRange},
|
||||
"from": []string{"-" + strconv.Itoa(rule.QueryRange) + "s"},
|
||||
}
|
||||
|
||||
res, err := goreq.Request{
|
||||
|
@ -33,7 +33,7 @@ func TestAlertRuleChangesDataAccess(t *testing.T) {
|
||||
Interval: "10",
|
||||
Title: "Alerting title",
|
||||
Description: "Alerting description",
|
||||
QueryRange: "5m",
|
||||
QueryRange: 3600,
|
||||
Aggregator: "avg",
|
||||
OrgId: FakeOrgId,
|
||||
},
|
||||
|
@ -28,7 +28,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
||||
Interval: "10",
|
||||
Title: "Alerting title",
|
||||
Description: "Alerting description",
|
||||
QueryRange: "5m",
|
||||
QueryRange: 3600,
|
||||
Aggregator: "avg",
|
||||
DatasourceId: 42,
|
||||
},
|
||||
@ -67,7 +67,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
||||
So(alert.QueryRefId, ShouldEqual, "A")
|
||||
So(alert.Title, ShouldEqual, "Alerting title")
|
||||
So(alert.Description, ShouldEqual, "Alerting description")
|
||||
So(alert.QueryRange, ShouldEqual, "5m")
|
||||
So(alert.QueryRange, ShouldEqual, 3600)
|
||||
So(alert.Aggregator, ShouldEqual, "avg")
|
||||
So(alert.State, ShouldEqual, "OK")
|
||||
So(alert.DatasourceId, ShouldEqual, 42)
|
||||
@ -191,7 +191,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
||||
Interval: "10",
|
||||
Title: "Alerting title",
|
||||
Description: "Alerting description",
|
||||
QueryRange: "5m",
|
||||
QueryRange: 3600,
|
||||
Aggregator: "avg",
|
||||
},
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func TestAlertingStateAccess(t *testing.T) {
|
||||
Interval: "10",
|
||||
Title: "Alerting title",
|
||||
Description: "Alerting description",
|
||||
QueryRange: "5m",
|
||||
QueryRange: 3600,
|
||||
Aggregator: "avg",
|
||||
},
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func addAlertMigrations(mg *Migrator) {
|
||||
{Name: "frequency", Type: DB_BigInt, Nullable: false},
|
||||
{Name: "title", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||
{Name: "description", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||
{Name: "query_range", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||
{Name: "query_range", Type: DB_Int, Nullable: false},
|
||||
{Name: "aggregator", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||
{Name: "state", Type: DB_NVarchar, Length: 255, Nullable: false},
|
||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||
|
Loading…
Reference in New Issue
Block a user