Documentation
¶
Index ¶
- Constants
- Variables
- func CloseBlocks(blocks []BlockInfo)
- func IsAggrChunk(enc chunkenc.Encoding) bool
- type AggrChunk
- type AggrChunkPool
- type AggrChunkWrapper
- func (c *AggrChunkWrapper) Appender() (chunkenc.Appender, error)
- func (c *AggrChunkWrapper) Bytes() []byte
- func (c *AggrChunkWrapper) Compact()
- func (c *AggrChunkWrapper) Encoding() chunkenc.Encoding
- func (c *AggrChunkWrapper) Iterator(it chunkenc.Iterator) chunkenc.Iterator
- func (c *AggrChunkWrapper) NumSamples() int
- func (c *AggrChunkWrapper) Reset(stream []byte)
- type AggrType
- type BlockInfo
- type BlockMeta
- type Client
- type ClosableSeriesSet
- type Config
- type Filter
- type ResolutionLevel
- type Stats
- type ThanosDownsample
- type ThanosFile
- type ThanosMeta
Constants ¶
const ChunkEncAggr = chunkenc.Encoding(0xff)
ChunkEncAggr is the top level encoding byte for the AggrChunk. It is defined by Thanos as 0xff to prevent collisions with Prometheus encodings.
Variables ¶
var AllAggrTypes = []AggrType{AggrCount, AggrSum, AggrMin, AggrMax, AggrCounter}
AllAggrTypes contains all supported aggregation types.
var ErrAggrNotExist = errors.New("aggregate does not exist")
ErrAggrNotExist is returned if a requested aggregation is not present in an AggrChunk.
Functions ¶
func CloseBlocks ¶
func CloseBlocks(blocks []BlockInfo)
CloseBlocks closes all blocks in the slice. Must be called only after all queriers on these blocks have been closed.
func IsAggrChunk ¶
IsAggrChunk checks if the encoding byte indicates this is an AggrChunk.
Types ¶
type AggrChunk ¶
type AggrChunk []byte
AggrChunk is a chunk that is composed of a set of aggregates for the same underlying data. Not all aggregates must be present. This is a read-only implementation for decoding Thanos downsampled blocks.
type AggrChunkPool ¶
type AggrChunkPool struct {
// contains filtered or unexported fields
}
AggrChunkPool is a custom Pool that understands AggrChunk encoding (0xff). It delegates standard encodings to the default pool and handles AggrChunk specially.
func NewAggrChunkPool ¶
func NewAggrChunkPool(aggrType AggrType) *AggrChunkPool
NewAggrChunkPool creates a new pool that handles AggrChunk encoding.
type AggrChunkWrapper ¶
type AggrChunkWrapper struct {
// contains filtered or unexported fields
}
AggrChunkWrapper wraps AggrChunk to implement chunkenc.Chunk interface. It delegates iteration to a specific aggregate type.
func NewAggrChunkWrapper ¶
func NewAggrChunkWrapper(data []byte, aggrType AggrType) *AggrChunkWrapper
NewAggrChunkWrapper creates a new AggrChunk wrapper for the specified aggregate type.
func (*AggrChunkWrapper) Appender ¶
func (c *AggrChunkWrapper) Appender() (chunkenc.Appender, error)
Appender returns an error since AggrChunk is read-only.
func (*AggrChunkWrapper) Bytes ¶
func (c *AggrChunkWrapper) Bytes() []byte
Bytes returns the underlying byte slice.
func (*AggrChunkWrapper) Compact ¶
func (c *AggrChunkWrapper) Compact()
Compact is a no-op for read-only AggrChunk.
func (*AggrChunkWrapper) Encoding ¶
func (c *AggrChunkWrapper) Encoding() chunkenc.Encoding
Encoding returns the AggrChunk encoding.
func (*AggrChunkWrapper) Iterator ¶
func (c *AggrChunkWrapper) Iterator(it chunkenc.Iterator) chunkenc.Iterator
Iterator returns an iterator for the specified aggregate type.
func (*AggrChunkWrapper) NumSamples ¶
func (c *AggrChunkWrapper) NumSamples() int
NumSamples returns the number of samples in the aggregate.
func (*AggrChunkWrapper) Reset ¶
func (c *AggrChunkWrapper) Reset(stream []byte)
Reset resets the chunk with new data.
type AggrType ¶
type AggrType uint8
AggrType represents an aggregation type in Thanos downsampled blocks.
Valid aggregation types matching Thanos definitions.
const AggrTypeNone AggrType = 255
AggrTypeNone indicates raw blocks with no aggregation. It is used as a sentinel to distinguish raw block processing from downsampled.
func ParseAggrType ¶
ParseAggrType parses aggregate type from string.
type BlockInfo ¶
type BlockInfo struct {
Block tsdb.BlockReader
Resolution ResolutionLevel
IsThanos bool
// Closer releases the block's resources (file descriptors, mmap).
// Must be called only after all queriers on this block have been closed.
Closer io.Closer
}
BlockInfo contains information about a block including Thanos metadata.
type BlockMeta ¶
type BlockMeta struct {
// Thanos-specific metadata
Thanos ThanosMeta `json:"thanos,omitempty"`
}
BlockMeta extends Prometheus BlockMeta with Thanos-specific fields.
func ReadBlockMeta ¶
ReadBlockMeta reads Thanos-extended block metadata from meta.json.
func (*BlockMeta) IsDownsampled ¶
IsDownsampled returns true if the block contains downsampled data.
func (*BlockMeta) Resolution ¶
func (m *BlockMeta) Resolution() ResolutionLevel
Resolution returns the block's downsampling resolution.
func (*BlockMeta) ResolutionSuffix ¶
ResolutionSuffix returns a suffix string for metric names based on resolution. For example: ":5m" or ":1h" for downsampled data, empty for raw data.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads Thanos snapshot blocks, including downsampled blocks with AggrChunk encoding.
func (*Client) Explore ¶
Explore fetches all available blocks from the snapshot with support for Thanos AggrChunk (downsampled blocks). It opens blocks with a custom pool that can decode AggrChunk encoding (0xff).
func (*Client) Read ¶
func (c *Client) Read(bi BlockInfo) (ClosableSeriesSet, error)
Read reads the given BlockInfo according to configured time and label filters. The returned ClosableSeriesSet automatically closes the underlying querier when fully consumed, but Close() should be called explicitly (e.g., via defer) to handle early returns.
type ClosableSeriesSet ¶
ClosableSeriesSet extends storage.SeriesSet with a Close method for explicit cleanup.
type ResolutionLevel ¶
type ResolutionLevel int64
ResolutionLevel represents the downsampling resolution.
const ( // ResolutionRaw is for raw, non-downsampled data. ResolutionRaw ResolutionLevel = 0 // Resolution5m is for 5-minute downsampled data (300000 ms). Resolution5m ResolutionLevel = 300000 // Resolution1h is for 1-hour downsampled data (3600000 ms). Resolution1h ResolutionLevel = 3600000 )
func (ResolutionLevel) String ¶
func (r ResolutionLevel) String() string
String returns human-readable resolution string.
type Stats ¶
type Stats struct {
Filtered bool
MinTime int64
MaxTime int64
Samples uint64
Series uint64
Blocks int
SkippedBlocks int
}
Stats represents data migration stats for Thanos blocks.
type ThanosDownsample ¶
type ThanosDownsample struct {
// Resolution is the downsampling resolution in milliseconds.
// 0 means raw data (no downsampling).
// 300000 (5 minutes) or 3600000 (1 hour) for downsampled data.
Resolution int64 `json:"resolution"`
}
ThanosDownsample contains downsampling resolution info.
type ThanosFile ¶
type ThanosFile struct {
RelPath string `json:"rel_path"`
SizeBytes int64 `json:"size_bytes,omitempty"`
}
ThanosFile contains metadata about a file in the block.
type ThanosMeta ¶
type ThanosMeta struct {
// Labels are external labels identifying the producer.
Labels map[string]string `json:"labels,omitempty"`
// Downsample contains downsampling information.
Downsample ThanosDownsample `json:"downsample,omitempty"`
// Source indicates where the block came from.
Source string `json:"source,omitempty"`
// SegmentFiles contains list of segment files in the block.
SegmentFiles []string `json:"segment_files,omitempty"`
// Files contains metadata about files in the block.
Files []ThanosFile `json:"files,omitempty"`
}
ThanosMeta contains Thanos-specific block metadata.