Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ loaders: tsbs_load \
tsbs_load_cassandra \
tsbs_load_clickhouse \
tsbs_load_cratedb \
tsbs_load_doris \
tsbs_load_influx \
tsbs_load_mongo \
tsbs_load_prometheus \
Expand All @@ -32,6 +33,7 @@ runners: tsbs_run_queries_akumuli \
tsbs_run_queries_cassandra \
tsbs_run_queries_clickhouse \
tsbs_run_queries_cratedb \
tsbs_run_queries_doris \
tsbs_run_queries_influx \
tsbs_run_queries_mongo \
tsbs_run_queries_siridb \
Expand Down Expand Up @@ -66,3 +68,8 @@ lint:

fmt:
$(GOFMT) ./...

clean:
@echo 'clean you make directory "./bin"';\
rm -rf bin

18 changes: 11 additions & 7 deletions cmd/tsbs_generate_queries/databases/clickhouse/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ const clickhouseTimeStringFormat = "2006-01-02 15:04:05"
// SELECT MAX(metric1), ..., MAX(metricN)
// FROM cpu
// WHERE
// (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N')
// AND time >= '$HOUR_START'
// AND time < '$HOUR_END'
//
// (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N')
// AND time >= '$HOUR_START'
// AND time < '$HOUR_END'
//
// GROUP BY hour
// ORDER BY hour
//
Expand Down Expand Up @@ -137,7 +139,7 @@ func (d *Devops) GroupByTimeAndPrimaryTag(qi query.Query, numMetrics int) {
hostnameField := "hostname"
joinClause := ""
if d.UseTags {
joinClause = "ANY INNER JOIN tags USING (id)"
joinClause = "INNER JOIN tags USING (id)"
}

sql := fmt.Sprintf(`
Expand Down Expand Up @@ -290,9 +292,11 @@ func (d *Devops) LastPointPerHost(qi query.Query) {
// SELECT minute, max(metric1), ..., max(metricN)
// FROM cpu
// WHERE
// (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N')
// AND time >= '$HOUR_START'
// AND time < '$HOUR_END'
//
// (hostname = '$HOSTNAME_1' OR ... OR hostname = '$HOSTNAME_N')
// AND time >= '$HOUR_START'
// AND time < '$HOUR_END'
//
// GROUP BY minute
// ORDER BY minute ASC
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func TestGroupByTimeAndPrimaryTag(t *testing.T) {
hour,
id
) AS cpu_avg
ANY INNER JOIN tags USING (id)
INNER JOIN tags USING (id)
ORDER BY
hour ASC,
hostname
Expand Down
44 changes: 44 additions & 0 deletions cmd/tsbs_generate_queries/databases/doris/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package doris

import (
"time"

"github.com/timescale/tsbs/cmd/tsbs_generate_queries/uses/devops"
"github.com/timescale/tsbs/cmd/tsbs_generate_queries/utils"
"github.com/timescale/tsbs/pkg/query"
)

// BaseGenerator contains settings specific for Doris.
type BaseGenerator struct {
UseTags bool
}

// GenerateEmptyQuery returns an empty query.Doris.
func (g *BaseGenerator) GenerateEmptyQuery() query.Query {
return query.NewDoris()
}

// fill Query fills the query struct with data
func (g *BaseGenerator) fillInQuery(qi query.Query, humanLabel, humanDesc, table, sql string) {
q := qi.(*query.Doris)
q.HumanLabel = []byte(humanLabel)
q.HumanDescription = []byte(humanDesc)
q.Table = []byte(table)
q.SqlQuery = []byte(sql)
}

// NewDevops creates a new devops use case query generator.
func (g *BaseGenerator) NewDevops(start, end time.Time, scale int) (utils.QueryGenerator, error) {
core, err := devops.NewCore(start, end, scale)

if err != nil {
return nil, err
}

d := &Devops{
BaseGenerator: g,
Core: core,
}

return d, nil
}
Loading