chunk

package
v0.0.0-...-54ca42f Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunksToMatrix

func ChunksToMatrix(chunks []Chunk) (model.Matrix, error)

ChunksToMatrix converts a slice of chunks into a model.Matrix.

Types

type ByID

type ByID []Chunk

ByID allow you to sort chunks by ID

func (ByID) Len

func (cs ByID) Len() int

func (ByID) Less

func (cs ByID) Less(i, j int) bool

func (ByID) Swap

func (cs ByID) Swap(i, j int)

type Cache

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

Cache type caches chunks

func NewCache

func NewCache(cfg CacheConfig) *Cache

NewCache makes a new Cache

func (*Cache) FetchChunkData

func (c *Cache) FetchChunkData(ctx context.Context, userID string, chunks []Chunk) (found []Chunk, missing []Chunk, err error)

FetchChunkData gets chunks from the chunk cache.

func (*Cache) StoreChunkData

func (c *Cache) StoreChunkData(ctx context.Context, userID string, chunk *Chunk) error

StoreChunkData serializes and stores a chunk in the chunk cache.

func (*Cache) StoreChunks

func (c *Cache) StoreChunks(ctx context.Context, userID string, chunks []Chunk) error

StoreChunks serializes and stores multiple chunks in the chunk cache.

type CacheConfig

type CacheConfig struct {
	Expiration time.Duration
	// contains filtered or unexported fields
}

CacheConfig is config to make a Cache

func (*CacheConfig) RegisterFlags

func (cfg *CacheConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type Chunk

type Chunk struct {
	ID      string       `json:"-"`
	From    model.Time   `json:"from"`
	Through model.Time   `json:"through"`
	Metric  model.Metric `json:"metric"`

	// We never use Delta encoding (the zero value), so if this entry is
	// missing, we default to DoubleDelta.
	Encoding prom_chunk.Encoding `json:"encoding"`
	Data     prom_chunk.Chunk    `json:"-"`
	// contains filtered or unexported fields
}

Chunk contains encoded timeseries data

func NewChunk

func NewChunk(fp model.Fingerprint, metric model.Metric, c prom_chunk.Chunk, firstTime, lastTime model.Time) Chunk

NewChunk creates a new chunk

type DynamoTableManager

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

DynamoTableManager creates and manages the provisioned throughput on DynamoDB tables

func NewDynamoTableManager

func NewDynamoTableManager(cfg TableManagerConfig) (*DynamoTableManager, error)

NewDynamoTableManager makes a new DynamoTableManager

func (*DynamoTableManager) Start

func (m *DynamoTableManager) Start()

Start the DynamoTableManager

func (*DynamoTableManager) Stop

func (m *DynamoTableManager) Stop()

Stop the DynamoTableManager

type IndexEntry

type IndexEntry struct {
	TableName string
	HashValue string

	// For writes, RangeValue will always be set.
	RangeValue []byte

	// For reads, one of RangeValuePrefix or RangeValueStart might be set:
	// - If RangeValuePrefix is not nil, must read all keys with that prefix.
	// - If RangeValueStart is not nil, must read all keys from there onwards.
	// - If neither is set, must read all keys for that row.
	RangeValuePrefix []byte
	RangeValueStart  []byte
}

IndexEntry describes an entry in the chunk index

type Memcache

type Memcache interface {
	GetMulti(keys []string) (map[string]*memcache.Item, error)
	Set(item *memcache.Item) error
}

Memcache caches things

type MemcacheClient

type MemcacheClient struct {
	*memcache.Client
	// contains filtered or unexported fields
}

MemcacheClient is a memcache client that gets its server list from SRV records, and periodically updates that ServerList.

func NewMemcacheClient

func NewMemcacheClient(cfg MemcacheConfig) *MemcacheClient

NewMemcacheClient creates a new MemcacheClient that gets its server list from SRV and updates the server list on a regular basis.

func (*MemcacheClient) Stop

func (c *MemcacheClient) Stop()

Stop the memcache client.

type MemcacheConfig

type MemcacheConfig struct {
	Host           string
	Service        string
	Timeout        time.Duration
	UpdateInterval time.Duration
}

MemcacheConfig defines how a MemcacheClient should be constructed.

func (*MemcacheConfig) RegisterFlags

func (cfg *MemcacheConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type PeriodicTableConfig

type PeriodicTableConfig struct {
	UsePeriodicTables    bool
	TablePrefix          string
	TablePeriod          time.Duration
	PeriodicTableStartAt util.DayValue
}

PeriodicTableConfig for the use of periodic tables (ie, weekly talbes). Can control when to start the periodic tables, how long the period should be, and the prefix to give the tables.

func (*PeriodicTableConfig) RegisterFlags

func (cfg *PeriodicTableConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type ReadBatch

type ReadBatch interface {
	Len() int
	RangeValue(index int) []byte

	// Value is deprecated - it exists to support an old schema where the chunk
	// metadata was written to the chunk index.
	Value(index int) []byte
}

ReadBatch represents the results of a QueryPages

type S3Client

type S3Client interface {
	PutObject(*s3.PutObjectInput) (*s3.PutObjectOutput, error)
	GetObject(*s3.GetObjectInput) (*s3.GetObjectOutput, error)
}

S3Client is a client for S3

func NewS3Client

func NewS3Client(s3URL string) (S3Client, string, error)

NewS3Client makes a new S3Client

type Schema

type Schema interface {
	// When doing a write, use this method to return the list of entries you should write to.
	GetWriteEntries(from, through model.Time, userID string, metricName model.LabelValue, labels model.Metric, chunkID string) ([]IndexEntry, error)

	// When doing a read, use these methods to return the list of entries you should query
	GetReadEntriesForMetric(from, through model.Time, userID string, metricName model.LabelValue) ([]IndexEntry, error)
	GetReadEntriesForMetricLabel(from, through model.Time, userID string, metricName model.LabelValue, labelName model.LabelName) ([]IndexEntry, error)
	GetReadEntriesForMetricLabelValue(from, through model.Time, userID string, metricName model.LabelValue, labelName model.LabelName, labelValue model.LabelValue) ([]IndexEntry, error)
}

Schema interface defines methods to calculate the hash and range keys needed to write or read chunks from the external index.

type SchemaConfig

type SchemaConfig struct {
	PeriodicTableConfig
	OriginalTableName string

	// After midnight on this day, we start bucketing indexes by day instead of by
	// hour.  Only the day matters, not the time within the day.
	DailyBucketsFrom util.DayValue

	// After this time, we will only query for base64-encoded label values.
	Base64ValuesFrom util.DayValue

	// After this time, we will read and write v4 schemas.
	V4SchemaFrom util.DayValue

	// After this time, we will read and write v5 schemas.
	V5SchemaFrom util.DayValue
}

SchemaConfig contains the config for our chunk index schemas

func (*SchemaConfig) RegisterFlags

func (cfg *SchemaConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type StorageClient

type StorageClient interface {
	// For the write path
	NewWriteBatch() WriteBatch
	BatchWrite(context.Context, WriteBatch) error

	// For the read path
	QueryPages(ctx context.Context, entry IndexEntry, callback func(result ReadBatch, lastPage bool) (shouldContinue bool)) error

	// For table management
	ListTables() ([]string, error)
	CreateTable(name string, readCapacity, writeCapacity int64) error
	DescribeTable(name string) (readCapacity, writeCapacity int64, status string, err error)
	UpdateTable(name string, readCapacity, writeCapacity int64) error
}

StorageClient is a client for DynamoDB

func NewDynamoDBClient

func NewDynamoDBClient(dynamoDBURL string) (StorageClient, string, error)

NewDynamoDBClient makes a new DynamoDBClient

type Store

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

Store implements Store

func NewStore

func NewStore(cfg StoreConfig) (*Store, error)

NewStore makes a new ChunkStore

func (*Store) Get

func (c *Store) Get(ctx context.Context, from, through model.Time, allMatchers ...*metric.LabelMatcher) ([]Chunk, error)

Get implements ChunkStore

func (*Store) Put

func (c *Store) Put(ctx context.Context, chunks []Chunk) error

Put implements ChunkStore

type StoreConfig

type StoreConfig struct {
	SchemaConfig
	CacheConfig
	S3       util.URLValue
	DynamoDB util.URLValue
	// contains filtered or unexported fields
}

StoreConfig specifies config for a ChunkStore

func (*StoreConfig) RegisterFlags

func (cfg *StoreConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type TableManagerConfig

type TableManagerConfig struct {
	DynamoDB             util.URLValue
	DynamoDBPollInterval time.Duration

	PeriodicTableConfig

	// duration a table will be created before it is needed.
	CreationGracePeriod        time.Duration
	MaxChunkAge                time.Duration
	ProvisionedWriteThroughput int64
	ProvisionedReadThroughput  int64
	InactiveWriteThroughput    int64
	InactiveReadThroughput     int64
	// contains filtered or unexported fields
}

TableManagerConfig is the config for a DynamoTableManager

func (*TableManagerConfig) RegisterFlags

func (cfg *TableManagerConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type WriteBatch

type WriteBatch interface {
	Add(tableName, hashValue string, rangeValue []byte)
}

WriteBatch represents a batch of writes

Jump to

Keyboard shortcuts

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