Merge branch 'master' of github.com:grafana/grafana

This commit is contained in:
Torkel Ödegaard
2016-12-15 13:57:05 +01:00
9 changed files with 82 additions and 27 deletions
+3 -2
View File
@@ -20,9 +20,10 @@ const (
)
const (
NoDataSetOK NoDataOption = "ok"
NoDataSetNoData NoDataOption = "no_data"
NoDataSetAlerting NoDataOption = "alerting"
NoDataKeepState NoDataOption = "keep_state"
NoDataSetAlerting NoDataOption = "alerting"
)
const (
@@ -35,7 +36,7 @@ func (s AlertStateType) IsValid() bool {
}
func (s NoDataOption) IsValid() bool {
return s == NoDataSetNoData || s == NoDataSetAlerting || s == NoDataKeepState
return s == NoDataSetNoData || s == NoDataSetAlerting || s == NoDataKeepState || s == NoDataSetOK
}
func (s NoDataOption) ToAlertState() AlertStateType {
+1 -1
View File
@@ -94,7 +94,7 @@ func createDialer() (*gomail.Dialer, error) {
if setting.Smtp.CertFile != "" {
cert, err := tls.LoadX509KeyPair(setting.Smtp.CertFile, setting.Smtp.KeyFile)
if err != nil {
return nil, err
return nil, fmt.Errorf("Could not load cert or key file. error: %v", err)
}
tlsconfig.Certificates = []tls.Certificate{cert}
}
+3 -1
View File
@@ -49,7 +49,9 @@ func (qp *QueryParser) Parse(model *simplejson.Json, dsInfo *models.DataSource,
return nil, err
}
functions = append(functions, f)
if f.Func != "" {
functions = append(functions, f)
}
}
query.FunctionList = functions
+2
View File
@@ -81,6 +81,8 @@ func (parser *ResponseParser) Parse(res *http.Response, queryRef *Query) ([]*tsd
if key == "cluster" && queryRef.AddClusterToAlias {
namePrefix += value + " "
}
}
for key, value := range mqeSerie.Tagset {
if key == "host" && queryRef.AddHostToAlias {
namePrefix += value + " "
}
+22
View File
@@ -49,6 +49,28 @@ func TestWildcardExpansion(t *testing.T) {
So(expandeQueries[2].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.1.idle`|aggregate.min {cpu} where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
})
Convey("With two aggregate functions", func() {
query := &Query{
Metrics: []Metric{
Metric{Metric: "os.cpu.3.idle", Alias: ""},
},
Hosts: []string{"staples-lab-1", "staples-lab-2"},
Cluster: []string{"demoapp-1", "demoapp-2"},
AddClusterToAlias: false,
AddHostToAlias: false,
FunctionList: []Function{
Function{Func: "aggregate.min"},
Function{Func: "aggregate.max"},
},
TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
}
expandeQueries, err := query.Build(availableMetrics)
So(err, ShouldBeNil)
So(len(expandeQueries), ShouldEqual, 1)
So(expandeQueries[0].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.3.idle`|aggregate.min|aggregate.max where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
})
Convey("Containg wildcard series", func() {
query := &Query{
Metrics: []Metric{