Documentation ¶
Overview ¶
Copyright 2019 grafana
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copied from github.com/grafana/cortex-tools
Copyright 2019 grafana ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 grafana ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 grafana ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 grafana ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 grafana ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func AddLabelToLabelSet(labelSets [][]prompb.Label, lbl LabelDesc) [][]prompb.Label
- func JitterUp(duration time.Duration, jitter float64) time.Duration
- func NewQueryClient(url, tenantName, username, password string) (v1.API, error)
- func ShardByAllLabels(userID string, labels []prompb.Label) uint32
- func ShardByUser(userID string) uint32
- type BatchReq
- type Config
- type ExprTemplateData
- type LabelDesc
- type Query
- type QueryConfig
- type QueryDesc
- type QueryRunner
- func (q *QueryRunner) ExecuteQuery(ctx context.Context, queryReq Query) error
- func (q *QueryRunner) GetRandomAPIClient() (v1.API, error)
- func (q *QueryRunner) QueryWorker(queryChan chan Query)
- func (q *QueryRunner) ResolveAddrs() error
- func (q *QueryRunner) ResolveAddrsLoop(ctx context.Context)
- func (q *QueryRunner) Run(ctx context.Context) error
- type QueryWorkload
- type RingCheckConfig
- type RingChecker
- type Runner
- type SeriesDesc
- type SeriesType
- type TenantIDRoundTripper
- type Timeseries
- type WorkloadDesc
- type WriteBenchConfig
- type WriteBenchmarkRunner
- func (w *WriteBenchmarkRunner) GetRandomWriteClient() (*WriteClient, error)
- func (w *WriteBenchmarkRunner) ResolveAddrs() error
- func (w *WriteBenchmarkRunner) ResolveAddrsLoop(ctx context.Context)
- func (w *WriteBenchmarkRunner) Run(ctx context.Context) error
- func (w *WriteBenchmarkRunner) SendBatch(ctx context.Context, batch []prompb.TimeSeries) error
- func (w *WriteBenchmarkRunner) WriteWorker(batchChan chan BatchReq)
- type WriteClient
- type WriteDesc
- type WriteWorkload
Constants ¶
This section is empty.
Variables ¶
var UserAgent = fmt.Sprintf("Benchtool/%s", version.Version)
Functions ¶
func AddLabelToLabelSet ¶
func JitterUp ¶
JitterUp adds random jitter to the duration.
This adds or subtracts time from the duration within a given jitter fraction. For example for 10s and jitter 0.1, it will return a time within [9s, 11s])
Reference: https://godoc.org/github.com/grpc-ecosystem/go-grpc-middleware/util/backoffutils
func NewQueryClient ¶
func ShardByAllLabels ¶
This function generates different values for different order of same labels.
func ShardByUser ¶
Types ¶
type BatchReq ¶
type BatchReq struct { Batch []prompb.TimeSeries Wg *sync.WaitGroup PutBack chan []prompb.TimeSeries }
type Config ¶
type Config struct { ID string `yaml:"id"` InstanceName string `yaml:"instance_name"` WorkloadFilePath string `yaml:"workload_file_path"` RingCheck RingCheckConfig `yaml:"ring_check"` Write WriteBenchConfig `yaml:"writes"` Query QueryConfig `yaml:"query"` }
func (*Config) RegisterFlags ¶
type ExprTemplateData ¶
type QueryConfig ¶
type QueryConfig struct { Enabled bool `yaml:"enabled"` Endpoint string `yaml:"endpoint"` BasicAuthUsername string `yaml:"basic_auth_username"` BasicAuthPasword string `yaml:"basic_auth_password"` }
func (*QueryConfig) RegisterFlags ¶
func (cfg *QueryConfig) RegisterFlags(f *flag.FlagSet)
type QueryDesc ¶
type QueryDesc struct { NumQueries int `yaml:"num_queries"` ExprTemplate string `yaml:"expr_template"` RequiredSeriesType SeriesType `yaml:"series_type"` Interval time.Duration `yaml:"interval"` TimeRange time.Duration `yaml:"time_range,omitempty"` Regex bool `yaml:"regex"` InjectExactSerierMatcher bool `yaml:"inject_exact_series_matcher"` }
type QueryRunner ¶
type QueryRunner struct {
// contains filtered or unexported fields
}
func NewQueryRunner ¶
func NewQueryRunner(id string, tenantName string, cfg QueryConfig, workload *QueryWorkload, logger log.Logger, reg prometheus.Registerer) (*QueryRunner, error)
func (*QueryRunner) ExecuteQuery ¶
func (q *QueryRunner) ExecuteQuery(ctx context.Context, queryReq Query) error
func (*QueryRunner) GetRandomAPIClient ¶
func (q *QueryRunner) GetRandomAPIClient() (v1.API, error)
func (*QueryRunner) QueryWorker ¶
func (q *QueryRunner) QueryWorker(queryChan chan Query)
func (*QueryRunner) ResolveAddrs ¶
func (q *QueryRunner) ResolveAddrs() error
func (*QueryRunner) ResolveAddrsLoop ¶
func (q *QueryRunner) ResolveAddrsLoop(ctx context.Context)
type QueryWorkload ¶
type QueryWorkload struct {
Queries []Query
}
func NewQueryWorkload ¶
func NewQueryWorkload(id string, desc WorkloadDesc) (*QueryWorkload, error)
type RingCheckConfig ¶
type RingCheckConfig struct { Enabled bool `yaml:"enabled"` MemberlistKV memberlist.KVConfig `yaml:"memberlist"` RingConfig ring.Config `yaml:"ring"` CheckInterval time.Duration `yaml:"check_interval"` }
func (*RingCheckConfig) RegisterFlagsWithPrefix ¶
func (cfg *RingCheckConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
type RingChecker ¶
type RingChecker struct { Ring *ring.Ring MemberlistKV *memberlist.KVInitService // contains filtered or unexported fields }
func NewRingChecker ¶
func NewRingChecker(id string, instanceName string, cfg RingCheckConfig, workload *WriteWorkload, logger log.Logger) (*RingChecker, error)
func (*RingChecker) Check ¶
func (r *RingChecker) Check()
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewBenchRunner ¶
func NewBenchRunner(cfg Config, logger log.Logger, reg prometheus.Registerer) (*Runner, error)
type SeriesDesc ¶
type SeriesDesc struct { Name string `yaml:"name"` Type SeriesType `yaml:"type"` StaticLabels map[string]string `yaml:"static_labels"` Labels []LabelDesc `yaml:"labels"` }
type SeriesType ¶
type SeriesType string
const ( GaugeZero SeriesType = "gauge-zero" GaugeRandom SeriesType = "gauge-random" CounterOne SeriesType = "counter-one" CounterRandom SeriesType = "counter-random" )
type TenantIDRoundTripper ¶
type TenantIDRoundTripper struct { TenantName string Next http.RoundTripper }
type Timeseries ¶
type Timeseries struct { LabelSets [][]prompb.Label LastValue float64 SeriesType SeriesType }
func SeriesDescToSeries ¶
func SeriesDescToSeries(seriesDescs []SeriesDesc) ([]*Timeseries, map[SeriesType]int)
type WorkloadDesc ¶
type WorkloadDesc struct { Replicas int `yaml:"replicas"` Series []SeriesDesc `yaml:"series"` QueryDesc []QueryDesc `yaml:"queries"` Write WriteDesc `yaml:"write_options"` }
type WriteBenchConfig ¶
type WriteBenchConfig struct { Enabled bool `yaml:"enabled"` Endpoint string `yaml:"endpoint"` BasicAuthUsername string `yaml:"basic_auth_username"` BasicAuthPasword string `yaml:"basic_auth_password"` ProxyURL string `yaml:"proxy_url"` }
func (*WriteBenchConfig) RegisterFlags ¶
func (cfg *WriteBenchConfig) RegisterFlags(f *flag.FlagSet)
type WriteBenchmarkRunner ¶
type WriteBenchmarkRunner struct {
// contains filtered or unexported fields
}
func NewWriteBenchmarkRunner ¶
func NewWriteBenchmarkRunner(id string, tenantName string, cfg WriteBenchConfig, workload *WriteWorkload, logger log.Logger, reg prometheus.Registerer) (*WriteBenchmarkRunner, error)
func (*WriteBenchmarkRunner) GetRandomWriteClient ¶
func (w *WriteBenchmarkRunner) GetRandomWriteClient() (*WriteClient, error)
func (*WriteBenchmarkRunner) ResolveAddrs ¶
func (w *WriteBenchmarkRunner) ResolveAddrs() error
func (*WriteBenchmarkRunner) ResolveAddrsLoop ¶
func (w *WriteBenchmarkRunner) ResolveAddrsLoop(ctx context.Context)
func (*WriteBenchmarkRunner) Run ¶
func (w *WriteBenchmarkRunner) Run(ctx context.Context) error
Run starts a loop that forwards metrics to the configured remote write endpoint
func (*WriteBenchmarkRunner) SendBatch ¶
func (w *WriteBenchmarkRunner) SendBatch(ctx context.Context, batch []prompb.TimeSeries) error
func (*WriteBenchmarkRunner) WriteWorker ¶
func (w *WriteBenchmarkRunner) WriteWorker(batchChan chan BatchReq)
type WriteClient ¶
WriteClient allows reading and writing from/to a remote HTTP endpoint.
func NewWriteClient ¶
func NewWriteClient(name string, tenantName string, conf *remote.ClientConfig, _ log.Logger, requestHistogram *prometheus.HistogramVec) (*WriteClient, error)
NewWriteClient creates a new client for remote write.
type WriteWorkload ¶
type WriteWorkload struct { Replicas int Series []*Timeseries TotalSeries int TotalSeriesTypeMap map[SeriesType]int // contains filtered or unexported fields }
func NewWriteWorkload ¶
func NewWriteWorkload(workloadDesc WorkloadDesc, reg prometheus.Registerer) *WriteWorkload
func (*WriteWorkload) GenerateTimeSeries ¶
func (w *WriteWorkload) GenerateTimeSeries(id string, t time.Time) []prompb.TimeSeries
func (*WriteWorkload) GenerateWriteBatch ¶
func (*WriteWorkload) GetSeriesBuffer ¶
func (w *WriteWorkload) GetSeriesBuffer(ctx context.Context) []prompb.TimeSeries