blockgen

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Profiles = ProfileMap{

		"realistic-k8s-2d-small": realisticK8s([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			2 * time.Hour,
		}, 1*time.Hour, 100, 50),
		"realistic-k8s-1w-small": realisticK8s([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			48 * time.Hour,
			48 * time.Hour,
			48 * time.Hour,
			2 * time.Hour,
		}, 1*time.Hour, 100, 50),
		"realistic-k8s-30d-tiny": realisticK8s([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			2 * time.Hour,
		}, 1*time.Hour, 1, 5),
		"realistic-k8s-365d-tiny": realisticK8s([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
		}, 1*time.Hour, 1, 5),
		"continuous-1w-small": continuous([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			8 * time.Hour,
			48 * time.Hour,
			48 * time.Hour,
			48 * time.Hour,
			2 * time.Hour,
		}, 100, 100),
		"continuous-30d-tiny": continuous([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			2 * time.Hour,
		}, 1, 5),
		"continuous-365d-tiny": continuous([]time.Duration{

			2 * time.Hour,
			2 * time.Hour,
			2 * time.Hour,
			8 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			176 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
			67 * 24 * time.Hour,
		}, 1, 5),
	}
)

Functions

func Generate

func Generate(ctx context.Context, logger log.Logger, goroutines int, dir string, block BlockSpec) (ulid.ULID, error)

Generate creates a block from given spec using given go routines in a given directory.

Types

type BlockSpec

type BlockSpec struct {
	metadata.Meta
	Series []SeriesSpec
}

TODO(bwplotka): Add option to create downsampled blocks.

type BlockWriter

type BlockWriter struct {
	// contains filtered or unexported fields
}

BlockWriter is implementation of Writer interface. Not designed to be thread-safe.

func NewTSDBBlockWriter

func NewTSDBBlockWriter(logger log.Logger, dir string) (*BlockWriter, error)

NewTSDBBlockWriter create new TSDB block writer.

The returned writer is generally not assumed to be thread-safe at the moment. It is assumed for single use.

The returned writer accumulates all series in memory until `Flush` is called. The repeated pattern of writes and flushes is allowed e.g.:

	for n < 1000 {
		// write a lot of stuff into memory
		w.Write()
		w.Write()

		// write block to disk
		w.Flush()
 }

The above loop will produce 1000 blocks on disk.

Note that the writer will not check if the target directory exists or contains anything at all. It is the caller's responsibility to ensure that the resulting blocks do not overlap etc.

func (*BlockWriter) Appender

func (w *BlockWriter) Appender(ctx context.Context) storage.Appender

Appender is not thread-safe. Returned Appender is thread-save however..

func (*BlockWriter) Flush

func (w *BlockWriter) Flush() (ulid.ULID, error)

Flush implements Writer interface. This is where actual block writing happens. After flush completes, no write can be done.

type GenType

type GenType string
const (
	Random  GenType = "RANDOM"
	Counter GenType = "COUNTER"
	Gauge   GenType = "GAUGE"
)

func (GenType) Create

func (g GenType) Create(random *rand.Rand, mint, maxt int64, opts seriesgen.Characteristics) (seriesgen.SeriesIterator, error)

type PlanFn

type PlanFn func(ctx context.Context, maxTime model.TimeOrDurationValue, extLset labels.Labels, blockEncoder func(BlockSpec) error) error

type ProfileMap

type ProfileMap map[string]PlanFn

func (ProfileMap) Keys

func (p ProfileMap) Keys() (keys []string)

type SeriesSpec

type SeriesSpec struct {
	Labels labels.Labels `yaml:"labels"`

	// Targets multiples labels by given targets.
	Targets int `yaml:"targets"`

	Type GenType `yaml:"type"`

	MinTime, MaxTime int64

	seriesgen.Characteristics `yaml:",inline"`
}

type Writer

type Writer interface {
	storage.Appendable

	// Flush writes current block to disk.
	// The block will contain values accumulated by `Write`.
	Flush() (ulid.ULID, error)
}

Writer is interface to write time series into Prometheus blocks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL