Documentation ¶
Overview ¶
Package block contains common functionality for interacting with TSDB blocks in the context of Thanos.
Index ¶
- Constants
- func Delete(ctx context.Context, bucket objstore.Bucket, id ulid.ULID) error
- func Download(ctx context.Context, logger log.Logger, bucket objstore.Bucket, id ulid.ULID, ...) error
- func DownloadMeta(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID) (metadata.Meta, error)
- func IgnoreCompleteOutsideChunk(mint int64, maxt int64, _ *chunks.Meta, curr *chunks.Meta) (bool, error)
- func IgnoreDuplicateOutsideChunk(_ int64, _ int64, last *chunks.Meta, curr *chunks.Meta) (bool, error)
- func IgnoreIssue347OutsideChunk(_ int64, maxt int64, _ *chunks.Meta, curr *chunks.Meta) (bool, error)
- func IsBlockDir(path string) (id ulid.ULID, ok bool)
- func ReadIndexCache(logger log.Logger, fn string) (version int, symbols map[uint32]string, lvals map[string][]string, ...)
- func Repair(logger log.Logger, dir string, id ulid.ULID, source metadata.SourceType, ...) (resid ulid.ULID, err error)
- func Upload(ctx context.Context, logger log.Logger, bkt objstore.Bucket, bdir string) error
- func VerifyIndex(logger log.Logger, fn string, minTime int64, maxTime int64) error
- func WriteIndexCache(logger log.Logger, indexFn string, fn string) error
- type Stats
Constants ¶
const ( // MetaFilename is the known JSON filename for meta information. MetaFilename = "meta.json" // IndexFilename is the known index file for block index. IndexFilename = "index" // ChunksDirname is the known dir name for chunks with compressed samples. ChunksDirname = "chunks" // DebugMetas is a directory for debug meta files that happen in the past. Useful for debugging. DebugMetas = "debug/metas" )
const IndexCacheFilename = "index.cache.json"
IndexCacheFilename is the canonical name for index cache files.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete removes directory that is mean to be block directory. NOTE: Prefer this method instead of objstore.Delete to avoid deleting empty dir (whole bucket) by mistake.
func Download ¶
func Download(ctx context.Context, logger log.Logger, bucket objstore.Bucket, id ulid.ULID, dst string) error
Download downloads directory that is mean to be block directory.
func DownloadMeta ¶
func DownloadMeta(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID) (metadata.Meta, error)
DownloadMeta downloads only meta file from bucket by block ID.
func ReadIndexCache ¶
func ReadIndexCache(logger log.Logger, fn string) ( version int, symbols map[uint32]string, lvals map[string][]string, postings map[labels.Label]index.Range, err error, )
ReadIndexCache reads an index cache file.
func Repair ¶
func Repair(logger log.Logger, dir string, id ulid.ULID, source metadata.SourceType, ignoreChkFns ...ignoreFnType) (resid ulid.ULID, err error)
Repair open the block with given id in dir and creates a new one with fixed data. It: - removes out of order duplicates - all "complete" outsiders (they will not accessed anyway) - removes all near "complete" outside chunks introduced by https://github.com/prometheus/tsdb/issues/347. Fixable inconsistencies are resolved in the new block. TODO(bplotka): https://github.com/improbable-eng/thanos/issues/378
func Upload ¶
Upload uploads block from given block dir that ends with block id. It makes sure cleanup is done on error to avoid partial block uploads. It also verifies basic features of Thanos block. TODO(bplotka): Ensure bucket operations have reasonable backoff retries.
func VerifyIndex ¶
VerifyIndex does a full run over a block index and verifies that it fulfills the order invariants.
Types ¶
type Stats ¶
type Stats struct { // TotalSeries represents total number of series in block. TotalSeries int // OutOfOrderSeries represents number of series that have out of order chunks. OutOfOrderSeries int // OutOfOrderChunks represents number of chunks that are out of order (older time range is after younger one) OutOfOrderChunks int // DuplicatedChunks represents number of chunks with same time ranges within same series, potential duplicates. DuplicatedChunks int // OutsideChunks represents number of all chunks that are before or after time range specified in block meta. OutsideChunks int // CompleteOutsideChunks is subset of OutsideChunks that will be never accessed. They are completely out of time range specified in block meta. CompleteOutsideChunks int // Issue347OutsideChunks represents subset of OutsideChunks that are outsiders caused by https://github.com/prometheus/tsdb/issues/347 // and is something that Thanos handle. // // Specifically we mean here chunks with minTime == block.maxTime and maxTime > block.MaxTime. These are // are segregated into separate counters. These chunks are safe to be deleted, since they are duplicated across 2 blocks. Issue347OutsideChunks int }
func GatherIndexIssueStats ¶
func GatherIndexIssueStats(logger log.Logger, fn string, minTime int64, maxTime int64) (stats Stats, err error)
GatherIndexIssueStats returns useful counters as well as outsider chunks (chunks outside of block time range) that helps to assess index health. It considers https://github.com/prometheus/tsdb/issues/347 as something that Thanos can handle. See Stats.Issue347OutsideChunks for details.
func (Stats) CriticalErr ¶
CriticalErr returns error if stats indicates critical block issue, that might solved only by manual repair procedure.
func (Stats) Issue347OutsideChunksErr ¶
Issue347OutsideChunksErr returns error if stats indicates issue347 block issue, that is repaired explicitly before compaction (on plan block).