|
|
@@ -31,19 +31,19 @@ func TestWildcardExpansion(t *testing.T) {
|
|
|
Metric{Metric: "os.cpu.2.idle", Alias: ""},
|
|
|
Metric{Metric: "os.cpu.1.idle", Alias: "cpu"},
|
|
|
},
|
|
|
- Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
|
|
- Apps: []string{"demoapp-1", "demoapp-2"},
|
|
|
- AddAppToAlias: false,
|
|
|
- AddHostToAlias: false,
|
|
|
- TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
|
|
+ Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
|
|
+ Cluster: []string{"demoapp-1", "demoapp-2"},
|
|
|
+ AddClusterToAlias: false,
|
|
|
+ AddHostToAlias: false,
|
|
|
+ TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
|
|
}
|
|
|
|
|
|
expandeQueries, err := query.Build(availableMetrics)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(expandeQueries), ShouldEqual, 3)
|
|
|
- So(expandeQueries[0].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.3.idle` where app in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
|
|
|
- So(expandeQueries[1].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.2.idle` where app in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
|
|
|
- So(expandeQueries[2].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.1.idle` {cpu} where app in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
|
|
|
+ So(expandeQueries[0].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.3.idle` where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
|
|
|
+ So(expandeQueries[1].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.2.idle` where cluster in ('demoapp-1', 'demoapp-2') and host in ('staples-lab-1', 'staples-lab-2') from %v to %v", from, to))
|
|
|
+ So(expandeQueries[2].RawQuery, ShouldEqual, fmt.Sprintf("`os.cpu.1.idle` {cpu} 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() {
|
|
|
@@ -51,10 +51,10 @@ func TestWildcardExpansion(t *testing.T) {
|
|
|
Metrics: []Metric{
|
|
|
Metric{Metric: "os.cpu*", Alias: ""},
|
|
|
},
|
|
|
- Hosts: []string{"staples-lab-1"},
|
|
|
- AddAppToAlias: false,
|
|
|
- AddHostToAlias: false,
|
|
|
- TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
|
|
+ Hosts: []string{"staples-lab-1"},
|
|
|
+ AddClusterToAlias: false,
|
|
|
+ AddHostToAlias: false,
|
|
|
+ TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
|
|
}
|
|
|
|
|
|
expandeQueries, err := query.Build(availableMetrics)
|