Add support for `tag_count` config option
It is now possible to configure arbitrarily many tags in a generic format. That is specifying the config option `tag_count=10` will add 10 tags to a series that are of the form `tag-key-n=tag-value` where n ranges from 0 to 9. Save current statepull/4168/head
parent
03f291d78c
commit
22a6f79a3c
|
@ -7,14 +7,14 @@
|
||||||
address = "localhost:8086"
|
address = "localhost:8086"
|
||||||
reset_database = true
|
reset_database = true
|
||||||
# doesnt do anything
|
# doesnt do anything
|
||||||
starting_point = "6m" # how far back in time to go
|
starting_point = 0 # how far back in time to go in weeks
|
||||||
|
|
||||||
[[series]]
|
[[series]]
|
||||||
point_count = 10 # number of points that will be written for each of the series
|
point_count = 10 # number of points that will be written for each of the series
|
||||||
measurement = "cpu"
|
measurement = "cpu"
|
||||||
series_count = 100000
|
series_count = 100000
|
||||||
|
|
||||||
tag_count = 20 # doesnt do anything yet
|
# tag_count = 20 # number of "generic" tags on a series (e.g. tag-key-1=tag-value, ... ,tag-key-20=tag-value)
|
||||||
|
|
||||||
[[series.tag]]
|
[[series.tag]]
|
||||||
key = "host"
|
key = "host"
|
||||||
|
|
|
@ -3,6 +3,7 @@ package runner
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/influxdb/influxdb/client"
|
"github.com/influxdb/influxdb/client"
|
||||||
|
@ -29,6 +30,7 @@ type series struct {
|
||||||
PointCount int `toml:"point_count"`
|
PointCount int `toml:"point_count"`
|
||||||
Measurement string `toml:"measurement"`
|
Measurement string `toml:"measurement"`
|
||||||
SeriesCount int `toml:"series_count"`
|
SeriesCount int `toml:"series_count"`
|
||||||
|
TagCount int `toml:"tag_count"`
|
||||||
Tags []tag `toml:"tag"`
|
Tags []tag `toml:"tag"`
|
||||||
Fields []field `toml:"field"`
|
Fields []field `toml:"field"`
|
||||||
}
|
}
|
||||||
|
@ -43,7 +45,7 @@ type write struct {
|
||||||
BatchInterval string `toml:"batch_interval"`
|
BatchInterval string `toml:"batch_interval"`
|
||||||
Database string `toml:"database"`
|
Database string `toml:"database"`
|
||||||
ResetDatabase bool `toml:"reset_database"`
|
ResetDatabase bool `toml:"reset_database"`
|
||||||
StartingPoint string `toml:"starting_time"`
|
StartingPoint int `toml:"starting_point"`
|
||||||
Address string `toml:"address"`
|
Address string `toml:"address"`
|
||||||
Precision string `toml:"precision"`
|
Precision string `toml:"precision"`
|
||||||
}
|
}
|
||||||
|
@ -115,10 +117,29 @@ func NewConfig() *Config {
|
||||||
func DecodeFile(s string) (*Config, error) {
|
func DecodeFile(s string) (*Config, error) {
|
||||||
t := &Config{}
|
t := &Config{}
|
||||||
|
|
||||||
|
// Decode the toml file
|
||||||
if _, err := toml.DecodeFile(s, t); err != nil {
|
if _, err := toml.DecodeFile(s, t); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize Config struct
|
||||||
|
// NOTE: Not happy with the implementation
|
||||||
|
// but it will do for now
|
||||||
|
for j, srs := range t.Series {
|
||||||
|
for i := 0; i < srs.TagCount; i++ {
|
||||||
|
|
||||||
|
tag := tag{
|
||||||
|
Key: fmt.Sprintf("tag-key-%d", i),
|
||||||
|
Value: "tag-value",
|
||||||
|
}
|
||||||
|
|
||||||
|
srs.Tags = append(srs.Tags, tag)
|
||||||
|
fmt.Println(srs)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Series[j] = srs
|
||||||
|
}
|
||||||
|
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +148,21 @@ func DecodeFile(s string) (*Config, error) {
|
||||||
// number of points that have been written
|
// number of points that have been written
|
||||||
// for the series `s`
|
// for the series `s`
|
||||||
type seriesIter struct {
|
type seriesIter struct {
|
||||||
s *series
|
s *series
|
||||||
count int
|
count int
|
||||||
|
timestamp time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *series) writeInterval(weeks int, i int) time.Time {
|
||||||
|
st := time.Duration(weeks) * 7 * 24 * time.Hour
|
||||||
|
w := st - (st/time.Duration(s.PointCount))*time.Duration(i)
|
||||||
|
return time.Now().Add(-1 * w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iter returns a pointer to a seriesIter
|
// Iter returns a pointer to a seriesIter
|
||||||
func (s *series) Iter() *seriesIter {
|
func (s *series) Iter(weeks int, i int) *seriesIter {
|
||||||
return &seriesIter{s: s, count: -1}
|
|
||||||
|
return &seriesIter{s: s, count: -1, timestamp: s.writeInterval(weeks, i)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTagMap returns a tagset
|
// newTagMap returns a tagset
|
||||||
|
@ -178,6 +207,7 @@ func (iter *seriesIter) Next() (client.Point, bool) {
|
||||||
Measurement: iter.s.Measurement,
|
Measurement: iter.s.Measurement,
|
||||||
Tags: iter.s.newTagMap(iter.count),
|
Tags: iter.s.newTagMap(iter.count),
|
||||||
Fields: iter.s.newFieldMap(),
|
Fields: iter.s.newFieldMap(),
|
||||||
|
Time: iter.timestamp,
|
||||||
}
|
}
|
||||||
b := iter.count < iter.s.SeriesCount
|
b := iter.count < iter.s.SeriesCount
|
||||||
return p, b
|
return p, b
|
||||||
|
|
|
@ -134,9 +134,6 @@ func resetDB(c *client.Client, database string) error {
|
||||||
// and the times that the test started at and ended as a `Timer`
|
// and the times that the test started at and ended as a `Timer`
|
||||||
func Run(cfg *Config) (totalPoints int, failedRequests int, responseTimes ResponseTimes, timer *Timer) {
|
func Run(cfg *Config) (totalPoints int, failedRequests int, responseTimes ResponseTimes, timer *Timer) {
|
||||||
|
|
||||||
timer = NewTimer()
|
|
||||||
defer timer.StopTimer()
|
|
||||||
|
|
||||||
c, err := cfg.NewClient()
|
c, err := cfg.NewClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -173,9 +170,12 @@ func Run(cfg *Config) (totalPoints int, failedRequests int, responseTimes Respon
|
||||||
Precision: cfg.Write.Precision,
|
Precision: cfg.Write.Precision,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer = NewTimer()
|
||||||
|
defer timer.StopTimer()
|
||||||
|
|
||||||
for _, testSeries := range cfg.Series {
|
for _, testSeries := range cfg.Series {
|
||||||
for i := 0; i < testSeries.PointCount; i++ {
|
for i := 0; i < testSeries.PointCount; i++ {
|
||||||
iter := testSeries.Iter()
|
iter := testSeries.Iter(cfg.Write.StartingPoint, i)
|
||||||
p, ok := iter.Next()
|
p, ok := iter.Next()
|
||||||
for ok {
|
for ok {
|
||||||
batch.Points = append(batch.Points, p)
|
batch.Points = append(batch.Points, p)
|
||||||
|
@ -217,7 +217,7 @@ func Run(cfg *Config) (totalPoints int, failedRequests int, responseTimes Respon
|
||||||
Database: cfg.Write.Database,
|
Database: cfg.Write.Database,
|
||||||
WriteConsistency: "any",
|
WriteConsistency: "any",
|
||||||
Precision: cfg.Write.Precision,
|
Precision: cfg.Write.Precision,
|
||||||
Time: time.Now(),
|
//Time: time.Now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p, ok = iter.Next()
|
p, ok = iter.Next()
|
||||||
|
|
Loading…
Reference in New Issue