Documentation ¶
Index ¶
- func MarshalBlock(dst []byte, b *Block) []byte
- func MarshalMetricNameRaw(dst []byte, labels []prompb.Label) []byte
- func PutMetricName(mn *MetricName)
- func RegexpCacheMisses() uint64
- func RegexpCacheRequests() uint64
- func RegexpCacheSize() int
- func UnmarshalBlock(dst *Block, src []byte) ([]byte, error)
- type Block
- func (b *Block) CopyFrom(src *Block)
- func (b *Block) Init(tsid *TSID, timestamps, values []int64, scale int16, precisionBits uint8)
- func (b *Block) MarshalData(timestampsBlockOffset, valuesBlockOffset uint64) ([]byte, []byte, []byte)
- func (b *Block) Reset()
- func (b *Block) RowsCount() int
- func (b *Block) Scale() int16
- func (b *Block) Timestamps() []int64
- func (b *Block) UnmarshalData() error
- func (b *Block) Values() []int64
- type IndexDBMetrics
- type MetricBlock
- type MetricName
- func (mn *MetricName) AddMissingTags(addTags []string, src *MetricName)
- func (mn *MetricName) AddTag(key, value string)
- func (mn *MetricName) AddTagBytes(key, value []byte)
- func (mn *MetricName) CopyFrom(src *MetricName)
- func (mn *MetricName) GetTagValue(tagKey string) []byte
- func (mn *MetricName) Marshal(dst []byte) []byte
- func (mn *MetricName) RemoveTag(tagKey string)
- func (mn *MetricName) RemoveTagsIgnoring(ignoringTags []string)
- func (mn *MetricName) RemoveTagsOn(onTags []string)
- func (mn *MetricName) Reset()
- func (mn *MetricName) ResetMetricGroup()
- func (mn *MetricName) String() string
- func (mn *MetricName) Unmarshal(src []byte) error
- type MetricRow
- type Metrics
- type Search
- type SearchQuery
- type Storage
- func (s *Storage) AddRows(mrs []MetricRow, precisionBits uint8) error
- func (s *Storage) CreateSnapshot() (string, error)
- func (s *Storage) DeleteMetrics(tfss []*TagFilters) (int, error)
- func (s *Storage) DeleteSnapshot(snapshotName string) error
- func (s *Storage) GetSeriesCount() (uint64, error)
- func (s *Storage) ListSnapshots() ([]string, error)
- func (s *Storage) MustClose()
- func (s *Storage) SearchTagEntries(maxTagKeys, maxTagValues int) ([]TagEntry, error)
- func (s *Storage) SearchTagKeys(maxTagKeys int) ([]string, error)
- func (s *Storage) SearchTagValues(tagKey []byte, maxTagValues int) ([]string, error)
- func (s *Storage) UpdateMetrics(m *Metrics)
- type TSID
- type TableMetrics
- type Tag
- type TagEntry
- type TagFilter
- type TagFilters
- type TimeRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalBlock ¶
MarshalBlock marshals b to dst.
b.MarshalData must be called on b before calling MarshalBlock.
func MarshalMetricNameRaw ¶
MarshalMetricNameRaw marshals labels to dst and returns the result.
The result must be unmarshaled with MetricName.unmarshalRaw
func RegexpCacheMisses ¶
func RegexpCacheMisses() uint64
RegexpCacheMisses returns the number of cache misses for regexp cache.
func RegexpCacheRequests ¶
func RegexpCacheRequests() uint64
RegexpCacheRequests returns the number of requests to regexp cache.
func RegexpCacheSize ¶
func RegexpCacheSize() int
RegexpCacheSize returns the number of cached regexps for tag filters.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents a block of time series values for a single TSID.
func (*Block) MarshalData ¶
func (b *Block) MarshalData(timestampsBlockOffset, valuesBlockOffset uint64) ([]byte, []byte, []byte)
MarshalData marshals the block into binary representation.
func (*Block) UnmarshalData ¶
UnmarshalData unmarshals block data.
type IndexDBMetrics ¶
type IndexDBMetrics struct { TagCacheSize uint64 TagCacheBytesSize uint64 TagCacheRequests uint64 TagCacheMisses uint64 UselessTagFiltersCacheSize uint64 UselessTagFiltersCacheBytesSize uint64 UselessTagFiltersCacheRequests uint64 UselessTagFiltersCacheMisses uint64 DeletedMetricsCount uint64 IndexDBRefCount uint64 MissingTSIDsForMetricID uint64 RecentHourMetricIDsSearchCalls uint64 RecentHourMetricIDsSearchHits uint64 DateMetricIDsSearchCalls uint64 DateMetricIDsSearchHits uint64 mergeset.TableMetrics }
IndexDBMetrics contains essential metrics for indexDB.
type MetricBlock ¶
MetricBlock is a time series block for a single metric.
func (*MetricBlock) Marshal ¶
func (mb *MetricBlock) Marshal(dst []byte) []byte
Marshal marshals MetricBlock to dst
type MetricName ¶
type MetricName struct { MetricGroup []byte // Tags are optional. They must be sorted by tag Key for canonical view. // Use sortTags method. Tags []Tag }
MetricName reperesents a metric name.
func (*MetricName) AddMissingTags ¶
func (mn *MetricName) AddMissingTags(addTags []string, src *MetricName)
AddMissingTags adds tags from src with keys matching addTags.
func (*MetricName) AddTag ¶
func (mn *MetricName) AddTag(key, value string)
AddTag adds new tag to mn with the given key and value.
func (*MetricName) AddTagBytes ¶
func (mn *MetricName) AddTagBytes(key, value []byte)
AddTagBytes adds new tag to mn with the given key and value.
func (*MetricName) CopyFrom ¶
func (mn *MetricName) CopyFrom(src *MetricName)
CopyFrom copies src to mn.
func (*MetricName) GetTagValue ¶
func (mn *MetricName) GetTagValue(tagKey string) []byte
GetTagValue returns tag value for the given tagKey.
func (*MetricName) Marshal ¶
func (mn *MetricName) Marshal(dst []byte) []byte
Marshal appends marshaled mn to dst and returns the result.
Tags must be sorted before calling this function.
func (*MetricName) RemoveTag ¶
func (mn *MetricName) RemoveTag(tagKey string)
RemoveTag removes a tag with the given tagKey
func (*MetricName) RemoveTagsIgnoring ¶
func (mn *MetricName) RemoveTagsIgnoring(ignoringTags []string)
RemoveTagsIgnoring removes all the tags included in ignoringTags.
func (*MetricName) RemoveTagsOn ¶
func (mn *MetricName) RemoveTagsOn(onTags []string)
RemoveTagsOn removes all the tags not included to onTags.
func (*MetricName) ResetMetricGroup ¶
func (mn *MetricName) ResetMetricGroup()
ResetMetricGroup resets mn.MetricGroup
func (*MetricName) String ¶
func (mn *MetricName) String() string
String returns user-readable representation of the metric name.
Use this function only for debug logging.
func (*MetricName) Unmarshal ¶
func (mn *MetricName) Unmarshal(src []byte) error
Unmarshal unmarshals mn from src.
type MetricRow ¶
type MetricRow struct { // MetricNameRaw contains raw metric name, which must be decoded // with MetricName.unmarshalRaw. MetricNameRaw []byte Timestamp int64 Value float64 }
MetricRow is a metric to insert into storage.
type Metrics ¶
type Metrics struct { TSIDCacheSize uint64 TSIDCacheBytesSize uint64 TSIDCacheRequests uint64 TSIDCacheMisses uint64 TSIDCacheCollisions uint64 MetricIDCacheSize uint64 MetricIDCacheBytesSize uint64 MetricIDCacheRequests uint64 MetricIDCacheMisses uint64 MetricIDCacheCollisions uint64 MetricNameCacheSize uint64 MetricNameCacheBytesSize uint64 MetricNameCacheRequests uint64 MetricNameCacheMisses uint64 MetricNameCacheCollisions uint64 DateMetricIDCacheSize uint64 DateMetricIDCacheBytesSize uint64 DateMetricIDCacheRequests uint64 DateMetricIDCacheMisses uint64 DateMetricIDCacheCollisions uint64 HourMetricIDCacheSize uint64 IndexDBMetrics IndexDBMetrics TableMetrics TableMetrics }
Metrics contains essential metrics for the Storage.
type Search ¶
type Search struct { // MetricBlock is updated with each Search.NextMetricBlock call. MetricBlock MetricBlock // MissingMetricNamesForMetricID is a counter of missing MetricID -> MetricName // entries during the search. // High rate may mean corrupted indexDB. MissingMetricNamesForMetricID uint64 // contains filtered or unexported fields }
Search is a search for time series.
func (*Search) Init ¶
func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMetrics int)
Init initializes s from the given storage, tfss and tr.
MustClose must be called when the search is done.
func (*Search) NextMetricBlock ¶
NextMetricBlock proceeds to the next MetricBlock.
type SearchQuery ¶
SearchQuery is used for sending search queries from vmselect to vmstorage.
func (*SearchQuery) Marshal ¶
func (sq *SearchQuery) Marshal(dst []byte) []byte
Marshal appends marshaled sq to dst and returns the result.
func (*SearchQuery) String ¶
func (sq *SearchQuery) String() string
String returns string representation of the search query.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage represents TSDB storage.
func OpenStorage ¶
OpenStorage opens storage on the given path with the given number of retention months.
func (*Storage) CreateSnapshot ¶
CreateSnapshot creates snapshot for s and returns the snapshot name.
func (*Storage) DeleteMetrics ¶
func (s *Storage) DeleteMetrics(tfss []*TagFilters) (int, error)
DeleteMetrics deletes all the metrics matching the given tfss.
Returns the number of metrics deleted.
func (*Storage) DeleteSnapshot ¶
DeleteSnapshot deletes the given snapshot.
func (*Storage) GetSeriesCount ¶
GetSeriesCount returns the approximate number of unique time series.
It includes the deleted series too and may count the same series up to two times - in db and extDB.
func (*Storage) ListSnapshots ¶
ListSnapshots returns sorted list of existing snapshots for s.
func (*Storage) SearchTagEntries ¶ added in v1.19.0
SearchTagEntries returns a list of (tagName -> tagValues) for (accountID, projectID).
func (*Storage) SearchTagKeys ¶
SearchTagKeys searches for tag keys
func (*Storage) SearchTagValues ¶
SearchTagValues searches for tag values for the given tagKey
func (*Storage) UpdateMetrics ¶
UpdateMetrics updates m with metrics from s.
type TSID ¶
type TSID struct { // MetricGroupID is the id of metric group inside the given project. // // MetricGroupID must be unique. // // Metric group contains metrics with the identical name like // 'memory_usage', 'http_requests', but with different // labels. For instance, the following metrics belong // to a metric group 'memory_usage': // // memory_usage{datacenter="foo1", job="bar1", instance="baz1:1234"} // memory_usage{datacenter="foo1", job="bar1", instance="baz2:1234"} // memory_usage{datacenter="foo1", job="bar2", instance="baz1:1234"} // memory_usage{datacenter="foo2", job="bar1", instance="baz2:1234"} MetricGroupID uint64 // JobID is the id of an individual job (aka service) // for the given project. // // JobID must be unique. // // Service may consist of multiple instances. // See https://prometheus.io/docs/concepts/jobs_instances/ for details. JobID uint32 // InstanceID is the id of an instance (aka process) // for the given project. // // InstanceID must be unique. // // See https://prometheus.io/docs/concepts/jobs_instances/ for details. InstanceID uint32 // MetricID is the unique id of the metric (time series). // // All the other TSID fields may be obtained by MetricID. MetricID uint64 }
TSID is unique id for a time series.
Time series blocks are sorted by TSID.
All the fields except MetricID are optional. They exist solely for better grouping of related metrics. It is OK if their meaning differ from their naming.
type TableMetrics ¶
type TableMetrics struct { PartitionsRefCount uint64 // contains filtered or unexported fields }
TableMetrics contains essential metrics for the table.
type Tag ¶
Tag represents a (key, value) tag for metric.
type TagEntry ¶ added in v1.19.0
type TagEntry struct { // Key is tagName Key string // Values contains all the values for Key. Values []string }
TagEntry contains (tagName -> tagValues) mapping
type TagFilter ¶
TagFilter represents a single tag filter from SearchQuery.
type TagFilters ¶
type TagFilters struct {
// contains filtered or unexported fields
}
TagFilters represents filters used for filtering tags.
func (*TagFilters) Add ¶
func (tfs *TagFilters) Add(key, value []byte, isNegative, isRegexp bool) error
Add adds the given tag filter to tfs.
MetricGroup must be encoded with nil key.
func (*TagFilters) String ¶
func (tfs *TagFilters) String() string
String returns human-readable value for tfs.
Source Files ¶
- block.go
- block_header.go
- block_stream_merger.go
- block_stream_reader.go
- block_stream_writer.go
- index_db.go
- inmemory_part.go
- merge.go
- metaindex_row.go
- metric_name.go
- part.go
- part_header.go
- part_search.go
- partition.go
- partition_search.go
- raw_block.go
- raw_row.go
- search.go
- storage.go
- table.go
- table_search.go
- tag_filters.go
- time.go
- tsid.go