Skip to content

Commit

Permalink
Add 12hr queries
Browse files Browse the repository at this point in the history
  • Loading branch information
rw committed Sep 7, 2016
1 parent c7a25bf commit 01ed208
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 37 deletions.
22 changes: 13 additions & 9 deletions bulk_query_gen/cassandra_devops_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,37 @@ func (d *CassandraDevops) Dispatch(i, scaleVar int) Query {
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 1)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 1, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 2)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 2, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteFourHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 4)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 4, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteEightHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 8)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 8, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteSixteenHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 16)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 16, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsageHourByMinuteThirtyTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 32)
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 32, time.Hour)
}

func (d *CassandraDevops) MaxCPUUsage12HoursByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*CassandraQuery), scaleVar, 1, 12*time.Hour)
}

// MaxCPUUsageHourByMinuteThirtyTwoHosts populates a Query with a query that looks like:
// SELECT max(usage_user) from cpu where (hostname = '$HOSTNAME_1' or ... or hostname = '$HOSTNAME_N') and time >= '$HOUR_START' and time < '$HOUR_END' group by time(1m)
func (d *CassandraDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int) {
interval := d.AllInterval.RandWindow(1 * time.Hour)
func (d *CassandraDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int, timeRange time.Duration) {
interval := d.AllInterval.RandWindow(timeRange)
nn := rand.Perm(scaleVar)[:nhosts]

tagSets := [][]string{}
Expand All @@ -70,7 +74,7 @@ func (d *CassandraDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhos
}
tagSets = append(tagSets, tagSet)

humanLabel := fmt.Sprintf("Cassandra max cpu, rand %4d hosts, rand 1hr by 1m", nhosts)
humanLabel := fmt.Sprintf("Cassandra max cpu, rand %4d hosts, rand %s by 1m", nhosts, timeRange)
q := qi.(*CassandraQuery)
q.HumanLabel = []byte(humanLabel)
q.HumanDescription = []byte(fmt.Sprintf("%s: %s", humanLabel, interval.StartString()))
Expand Down
21 changes: 21 additions & 0 deletions bulk_query_gen/cassandra_devops_singlehost_12hr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "time"

// CassandraDevopsSingleHost12hr produces Cassandra-specific queries for the devops single-host case.
type CassandraDevopsSingleHost12hr struct {
CassandraDevops
}

func NewCassandraDevopsSingleHost12hr(dbConfig DatabaseConfig, start, end time.Time) QueryGenerator {
underlying := newCassandraDevopsCommon(dbConfig, start, end).(*CassandraDevops)
return &CassandraDevopsSingleHost12hr{
CassandraDevops: *underlying,
}
}

func (d *CassandraDevopsSingleHost12hr) Dispatch(_, scaleVar int) Query {
q := NewCassandraQuery() // from pool
d.MaxCPUUsage12HoursByMinuteOneHost(q, scaleVar)
return q
}
2 changes: 2 additions & 0 deletions bulk_query_gen/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type Devops interface {
MaxCPUUsageHourByMinuteSixteenHosts(Query, int)
MaxCPUUsageHourByMinuteThirtyTwoHosts(Query, int)

MaxCPUUsage12HoursByMinuteOneHost(Query, int)

MeanCPUUsageDayByHourAllHostsGroupbyHost(Query, int)

//CountCPUUsageDayByHourAllHostsGroupbyHost(Query, int)
Expand Down
21 changes: 12 additions & 9 deletions bulk_query_gen/es_devops_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,42 @@ func (d *ElasticSearchDevops) Dispatch(i, scaleVar int) Query {
// MaxCPUUsageHourByMinuteOneHost populates a Query for getting the maximum CPU
// usage for one host over the course of an hour.
func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1, time.Hour)
}

// MaxCPUUsageHourByMinuteTwoHosts populates a Query for getting the maximum CPU
// usage for two hosts over the course of an hour.
func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 2)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 2, time.Hour)
}

// MaxCPUUsageHourByMinuteFourHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteFourHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 4)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 4, time.Hour)
}

// MaxCPUUsageHourByMinuteEightHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteEightHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 8)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 8, time.Hour)
}

// MaxCPUUsageHourByMinuteSixteenHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteSixteenHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 16)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 16, time.Hour)
}

func (d *ElasticSearchDevops) MaxCPUUsageHourByMinuteThirtyTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 32)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 32, time.Hour)
}
func (d *ElasticSearchDevops) MaxCPUUsage12HoursByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1, 12*time.Hour)
}

func (d *ElasticSearchDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int) {
interval := d.AllInterval.RandWindow(time.Hour)
func (d *ElasticSearchDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int, timeRange time.Duration) {
interval := d.AllInterval.RandWindow(timeRange)
nn := rand.Perm(scaleVar)[:nhosts]

hostnames := []string{}
Expand All @@ -101,7 +104,7 @@ func (d *ElasticSearchDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar,
Field: "usage_user",
})

humanLabel := []byte(fmt.Sprintf("Elastic max cpu, rand %4d hosts, rand 1hr by 1m", nhosts))
humanLabel := []byte(fmt.Sprintf("Elastic max cpu, rand %4d hosts, rand %s by 1m", nhosts, timeRange))
q := qi.(*HTTPQuery)
q.HumanLabel = humanLabel
q.HumanDescription = []byte(fmt.Sprintf("%s: %s", humanLabel, interval.StartString()))
Expand Down
21 changes: 21 additions & 0 deletions bulk_query_gen/es_devops_singlehost_12hr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "time"

// ElasticSearchDevopsSingleHost12hr produces ES-specific queries for the devops single-host case.
type ElasticSearchDevopsSingleHost12hr struct {
ElasticSearchDevops
}

func NewElasticSearchDevopsSingleHost12hr(dbConfig DatabaseConfig, start, end time.Time) QueryGenerator {
underlying := NewElasticSearchDevops(dbConfig, start, end).(*ElasticSearchDevops)
return &ElasticSearchDevopsSingleHost12hr{
ElasticSearchDevops: *underlying,
}
}

func (d *ElasticSearchDevopsSingleHost12hr) Dispatch(i, scaleVar int) Query {
q := NewHTTPQuery() // from pool
d.MaxCPUUsage12HoursByMinuteOneHost(q, scaleVar)
return q
}
22 changes: 13 additions & 9 deletions bulk_query_gen/influx_devops_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,37 @@ func (d *InfluxDevops) Dispatch(i, scaleVar int) Query {
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 2)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 2, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteFourHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 4)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 4, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteEightHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 8)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 8, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteSixteenHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 16)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 16, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsageHourByMinuteThirtyTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 32)
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 32, time.Hour)
}

func (d *InfluxDevops) MaxCPUUsage12HoursByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*HTTPQuery), scaleVar, 1, 12*time.Hour)
}

// MaxCPUUsageHourByMinuteThirtyTwoHosts populates a Query with a query that looks like:
// SELECT max(usage_user) from cpu where (hostname = '$HOSTNAME_1' or ... or hostname = '$HOSTNAME_N') and time >= '$HOUR_START' and time < '$HOUR_END' group by time(1m)
func (d *InfluxDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int) {
interval := d.AllInterval.RandWindow(1 * time.Hour)
func (d *InfluxDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int, timeRange time.Duration) {
interval := d.AllInterval.RandWindow(timeRange)
nn := rand.Perm(scaleVar)[:nhosts]

hostnames := []string{}
Expand All @@ -82,7 +86,7 @@ func (d *InfluxDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts
v.Set("db", d.DatabaseName)
v.Set("q", fmt.Sprintf("SELECT max(usage_user) from cpu where (%s) and time >= '%s' and time < '%s' group by time(1m)", combinedHostnameClause, interval.StartString(), interval.EndString()))

humanLabel := fmt.Sprintf("Influx max cpu, rand %4d hosts, rand 1hr by 1m", nhosts)
humanLabel := fmt.Sprintf("Influx max cpu, rand %4d hosts, rand %s by 1m", nhosts, timeRange)
q := qi.(*HTTPQuery)
q.HumanLabel = []byte(humanLabel)
q.HumanDescription = []byte(fmt.Sprintf("%s: %s", humanLabel, interval.StartString()))
Expand Down
22 changes: 22 additions & 0 deletions bulk_query_gen/influx_devops_singlehost_12hr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import "time"

// InfluxDevopsSingleHost12hr produces Influx-specific queries for the devops single-host case over a 12hr period.
type InfluxDevopsSingleHost12hr struct {
InfluxDevops
}

func NewInfluxDevopsSingleHost12hr(dbConfig DatabaseConfig, start, end time.Time) QueryGenerator {
underlying := newInfluxDevopsCommon(dbConfig, start, end).(*InfluxDevops)
return &InfluxDevopsSingleHost12hr{
InfluxDevops: *underlying,
}
}

func (d *InfluxDevopsSingleHost12hr) Dispatch(i, scaleVar int) Query {
q := NewHTTPQuery() // from pool
d.MaxCPUUsage12HoursByMinuteOneHost(q, scaleVar)
return q
}

8 changes: 7 additions & 1 deletion bulk_query_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ import (
// (This object is shown to the user when flag.Usage is called.)
var useCaseMatrix = map[string]map[string]map[string]QueryGeneratorMaker{
"devops": {
"single-host": {
"single-host-1-hr": {
"influx-http": NewInfluxDevopsSingleHost,
"es-http": NewElasticSearchDevopsSingleHost,
"cassandra": NewCassandraDevopsSingleHost,
"mongo": NewMongoDevopsSingleHost,
},
"single-host-12-hr": {
"influx-http": NewInfluxDevopsSingleHost12hr,
"es-http": NewElasticSearchDevopsSingleHost12hr,
"cassandra": NewCassandraDevopsSingleHost12hr,
"mongo": NewMongoDevopsSingleHost12hr,
},
"groupby": {
"influx-http": NewInfluxDevopsGroupBy,
"es-http": NewElasticSearchDevopsGroupBy,
Expand Down
22 changes: 13 additions & 9 deletions bulk_query_gen/mongo_devops_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,43 @@ func (d *MongoDevops) Dispatch(i, scaleVar int) Query {
// MaxCPUUsageHourByMinuteOneHost populates a Query for getting the maximum CPU
// usage for one host over the course of an hour.
func (d *MongoDevops) MaxCPUUsageHourByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 1)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 1, time.Hour)
}

// MaxCPUUsageHourByMinuteTwoHosts populates a Query for getting the maximum CPU
// usage for two hosts over the course of an hour.
func (d *MongoDevops) MaxCPUUsageHourByMinuteTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 2)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 2, time.Hour)
}

// MaxCPUUsageHourByMinuteFourHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *MongoDevops) MaxCPUUsageHourByMinuteFourHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 4)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 4, time.Hour)
}

// MaxCPUUsageHourByMinuteEightHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *MongoDevops) MaxCPUUsageHourByMinuteEightHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 8)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 8, time.Hour)
}

// MaxCPUUsageHourByMinuteSixteenHosts populates a Query for getting the maximum CPU
// usage for four hosts over the course of an hour.
func (d *MongoDevops) MaxCPUUsageHourByMinuteSixteenHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 16)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 16, time.Hour)
}

func (d *MongoDevops) MaxCPUUsageHourByMinuteThirtyTwoHosts(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 32)
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 32, time.Hour)
}

func (d *MongoDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int) {
interval := d.AllInterval.RandWindow(time.Hour)
func (d *MongoDevops) MaxCPUUsage12HoursByMinuteOneHost(q Query, scaleVar int) {
d.maxCPUUsageHourByMinuteNHosts(q.(*MongoQuery), scaleVar, 1, 12*time.Hour)
}

func (d *MongoDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts int, timeRange time.Duration) {
interval := d.AllInterval.RandWindow(timeRange)
nn := rand.Perm(scaleVar)[:nhosts]

hostnames := []string{}
Expand Down Expand Up @@ -128,7 +132,7 @@ func (d *MongoDevops) maxCPUUsageHourByMinuteNHosts(qi Query, scaleVar, nhosts i
},
}

humanLabel := []byte(fmt.Sprintf("Mongo max cpu, rand %4d hosts, rand 1hr by 1m", nhosts))
humanLabel := []byte(fmt.Sprintf("Mongo max cpu, rand %4d hosts, rand %s by 1m", nhosts, timeRange))
q := qi.(*MongoQuery)
q.HumanLabel = humanLabel
q.BsonDoc = pipelineQuery
Expand Down
21 changes: 21 additions & 0 deletions bulk_query_gen/mongo_devops_singlehost_12hr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "time"

// MongoDevopsSingleHost produces Mongo-specific queries for the devops single-host case.
type MongoDevopsSingleHost12hr struct {
MongoDevops
}

func NewMongoDevopsSingleHost12hr(dbConfig DatabaseConfig, start, end time.Time) QueryGenerator {
underlying := NewMongoDevops(dbConfig, start, end).(*MongoDevops)
return &MongoDevopsSingleHost12hr{
MongoDevops: *underlying,
}
}

func (d *MongoDevopsSingleHost12hr) Dispatch(i, scaleVar int) Query {
q := NewMongoQuery() // from pool
d.MaxCPUUsage12HoursByMinuteOneHost(q, scaleVar)
return q
}

0 comments on commit 01ed208

Please sign in to comment.