Documentation
¶
Overview ¶
Package prom_plugin stores Prometheus samples in a World, scrapes exporters into it from approved Devices, and answers PromQL over it.
Each scrape target is one World object. Its root is a block-backed key-value tree holding the target's labels and scrape config, its series table, and one immutable segment per commit window. A Store appends samples to an in-memory window and commits the window as one segment, and a Queryable serves the fork's storage.Queryable interface from the committed segments of several targets. The spacewave-prom plugin registers the prom/target ObjectType, whose process scrapes the target on the Device its ProcessBinding approves.
Index ¶
- Constants
- Variables
- func NewFactory(b bus.Bus) controller.Factory
- func NewLabelSet(lset labels.Labels) *s4wave_prom.LabelSet
- func ToLabels(s *s4wave_prom.LabelSet) labels.Labels
- type Chunk
- func (m *Chunk) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Chunk) CloneVT() *Chunk
- func (this *Chunk) EqualMessageVT(thatMsg any) bool
- func (this *Chunk) EqualVT(that *Chunk) bool
- func (x *Chunk) GetData() []byte
- func (x *Chunk) GetEncoding() ChunkEncoding
- func (x *Chunk) GetMaxTime() int64
- func (x *Chunk) GetMinTime() int64
- func (x *Chunk) MarshalJSON() ([]byte, error)
- func (x *Chunk) MarshalProtoJSON(s *json.MarshalState)
- func (x *Chunk) MarshalProtoText() string
- func (m *Chunk) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Chunk) MarshalToVT(dAtA []byte) (int, error)
- func (m *Chunk) MarshalVT() (dAtA []byte, err error)
- func (*Chunk) ProtoMessage()
- func (x *Chunk) Reset()
- func (m *Chunk) SizeVT() (n int)
- func (x *Chunk) String() string
- func (x *Chunk) UnmarshalJSON(b []byte) error
- func (x *Chunk) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Chunk) UnmarshalVT(dAtA []byte) error
- type ChunkEncoding
- func (x ChunkEncoding) Enum() *ChunkEncoding
- func (x ChunkEncoding) MarshalJSON() ([]byte, error)
- func (x ChunkEncoding) MarshalProtoJSON(s *json.MarshalState)
- func (x ChunkEncoding) MarshalProtoText() string
- func (x ChunkEncoding) MarshalText() ([]byte, error)
- func (x ChunkEncoding) String() string
- func (x *ChunkEncoding) UnmarshalJSON(b []byte) error
- func (x *ChunkEncoding) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (x *ChunkEncoding) UnmarshalText(b []byte) error
- type CommitStats
- type Config
- func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Config) CloneVT() *Config
- func (c *Config) CommitWindow() time.Duration
- func (this *Config) EqualMessageVT(thatMsg any) bool
- func (this *Config) EqualVT(that *Config) bool
- func (c *Config) EqualsConfig(other config.Config) bool
- func (x *Config) GetCommitWindowMs() uint32
- func (c *Config) GetConfigID() string
- func (x *Config) MarshalJSON() ([]byte, error)
- func (x *Config) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config) MarshalProtoText() string
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (*Config) ProtoMessage()
- func (x *Config) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (x *Config) UnmarshalJSON(b []byte) error
- func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type Controller
- type Querier
- func (q *Querier) Close() error
- func (q *Querier) LabelNames(ctx context.Context, _ *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
- func (q *Querier) LabelValues(ctx context.Context, name string, _ *storage.LabelHints, ...) ([]string, annotations.Annotations, error)
- func (q *Querier) Select(ctx context.Context, _ bool, hints *storage.SelectHints, ...) storage.SeriesSet
- type Queryable
- type Segment
- func (m *Segment) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Segment) CloneVT() *Segment
- func (this *Segment) EqualMessageVT(thatMsg any) bool
- func (this *Segment) EqualVT(that *Segment) bool
- func (x *Segment) GetMaxTime() int64
- func (x *Segment) GetMinTime() int64
- func (x *Segment) GetSeries() []*SeriesChunks
- func (x *Segment) MarshalJSON() ([]byte, error)
- func (x *Segment) MarshalProtoJSON(s *json.MarshalState)
- func (x *Segment) MarshalProtoText() string
- func (m *Segment) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Segment) MarshalToVT(dAtA []byte) (int, error)
- func (m *Segment) MarshalVT() (dAtA []byte, err error)
- func (*Segment) ProtoMessage()
- func (x *Segment) Reset()
- func (m *Segment) SizeVT() (n int)
- func (x *Segment) String() string
- func (x *Segment) UnmarshalJSON(b []byte) error
- func (x *Segment) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Segment) UnmarshalVT(dAtA []byte) error
- type SeriesChunks
- func (m *SeriesChunks) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *SeriesChunks) CloneVT() *SeriesChunks
- func (this *SeriesChunks) EqualMessageVT(thatMsg any) bool
- func (this *SeriesChunks) EqualVT(that *SeriesChunks) bool
- func (x *SeriesChunks) GetChunks() []*Chunk
- func (x *SeriesChunks) GetSeries() uint64
- func (x *SeriesChunks) MarshalJSON() ([]byte, error)
- func (x *SeriesChunks) MarshalProtoJSON(s *json.MarshalState)
- func (x *SeriesChunks) MarshalProtoText() string
- func (m *SeriesChunks) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *SeriesChunks) MarshalToVT(dAtA []byte) (int, error)
- func (m *SeriesChunks) MarshalVT() (dAtA []byte, err error)
- func (*SeriesChunks) ProtoMessage()
- func (x *SeriesChunks) Reset()
- func (m *SeriesChunks) SizeVT() (n int)
- func (x *SeriesChunks) String() string
- func (x *SeriesChunks) UnmarshalJSON(b []byte) error
- func (x *SeriesChunks) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *SeriesChunks) UnmarshalVT(dAtA []byte) error
- type SeriesPage
- func (m *SeriesPage) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *SeriesPage) CloneVT() *SeriesPage
- func (this *SeriesPage) EqualMessageVT(thatMsg any) bool
- func (this *SeriesPage) EqualVT(that *SeriesPage) bool
- func (x *SeriesPage) GetFirstSeries() uint64
- func (x *SeriesPage) GetSeries() []*prom.LabelSet
- func (x *SeriesPage) MarshalJSON() ([]byte, error)
- func (x *SeriesPage) MarshalProtoJSON(s *json.MarshalState)
- func (x *SeriesPage) MarshalProtoText() string
- func (m *SeriesPage) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *SeriesPage) MarshalToVT(dAtA []byte) (int, error)
- func (m *SeriesPage) MarshalVT() (dAtA []byte, err error)
- func (*SeriesPage) ProtoMessage()
- func (x *SeriesPage) Reset()
- func (m *SeriesPage) SizeVT() (n int)
- func (x *SeriesPage) String() string
- func (x *SeriesPage) UnmarshalJSON(b []byte) error
- func (x *SeriesPage) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *SeriesPage) UnmarshalVT(dAtA []byte) error
- type SeriesSet
- type SeriesTable
- func (t *SeriesTable) Add(lset labels.Labels) uint64
- func (t *SeriesTable) Labels(num uint64) labels.Labels
- func (t *SeriesTable) LabelsFrom(from uint64) []labels.Labels
- func (t *SeriesTable) Len() uint64
- func (t *SeriesTable) Lookup(lset labels.Labels) (uint64, bool)
- func (t *SeriesTable) Truncate(n uint64)
- type StaticTargets
- type Store
- type StoreReader
- func (r *StoreReader) ForEachSegment(ctx context.Context, mint, maxt int64, fn func(*Segment) error) error
- func (r *StoreReader) Labels(ctx context.Context, matchers []*labels.Matcher) ([]labels.Labels, error)
- func (r *StoreReader) LastSegmentMaxTime(ctx context.Context) (int64, bool, error)
- func (r *StoreReader) Meta(ctx context.Context) (*s4wave_prom.TargetMeta, error)
- func (r *StoreReader) Select(ctx context.Context, mint, maxt int64, matchers []*labels.Matcher) ([]storage.Series, error)
- func (r *StoreReader) Table(ctx context.Context) (*SeriesTable, error)
- func (r *StoreReader) TargetLabels(ctx context.Context) (labels.Labels, error)
- type TargetLister
- type Window
Constants ¶
const ChunkSamples = 120
ChunkSamples is the number of samples after which a window starts a new chunk for a series, the same cut Prometheus uses for its head chunks.
const CompactSpan = 2 * time.Hour
CompactSpan is the time bucket that compaction merges a target's segments into, the length of a Prometheus block.
const ConfigID = ControllerID
ConfigID is the config identifier.
const ControllerID = "plugin/prom"
ControllerID is the controller identifier.
const DefaultCommitWindow = time.Minute
DefaultCommitWindow is the commit window of a config that sets none.
const PluginID = "spacewave-prom"
PluginID is the manifest ID of the Prometheus plugin.
Variables ¶
var ( // ErrReservedLabel is returned when a sample's labels carry a name that the // store's target labels already provide. ErrReservedLabel = errors.New("prom: label name is set by the target") // ErrCommitInProgress is returned when a store is committed while another // commit of the same store has not finished. ErrCommitInProgress = errors.New("prom: commit already in progress") // ErrStoodDown is returned when another writer took over a store's target. ErrStoodDown = errors.New("prom: another Device took over the target") // ErrCorruptStore is returned when a target's stored keys do not follow the // store layout. ErrCorruptStore = errors.New("prom: corrupt store") // ErrUnknownEncoding is returned when a stored chunk uses an encoding this // version cannot read. ErrUnknownEncoding = errors.New("prom: unknown chunk encoding") )
var ( ChunkEncoding_name = map[int32]string{ 0: "CHUNK_ENCODING_UNKNOWN", 1: "CHUNK_ENCODING_XOR", } ChunkEncoding_value = map[string]int32{ "CHUNK_ENCODING_UNKNOWN": 0, "CHUNK_ENCODING_XOR": 1, } )
Enum value maps for ChunkEncoding.
var Version = controller.MustParseVersion("0.0.1")
Version is the component version.
Functions ¶
func NewFactory ¶
func NewFactory(b bus.Bus) controller.Factory
NewFactory constructs the component factory.
func NewLabelSet ¶
func NewLabelSet(lset labels.Labels) *s4wave_prom.LabelSet
NewLabelSet converts a Prometheus label set to its stored form.
Types ¶
type Chunk ¶
type Chunk struct {
// MinTime is the first sample's timestamp in milliseconds.
MinTime int64 `protobuf:"varint,1,opt,name=min_time,json=minTime,proto3" json:"minTime,omitempty"`
// MaxTime is the last sample's timestamp in milliseconds.
MaxTime int64 `protobuf:"varint,2,opt,name=max_time,json=maxTime,proto3" json:"maxTime,omitempty"`
// Encoding is how Data encodes the samples.
Encoding ChunkEncoding `protobuf:"varint,3,opt,name=encoding,proto3" json:"encoding,omitempty"`
// Data holds the encoded samples.
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
// contains filtered or unexported fields
}
Chunk is a run of one series' samples in one encoding.
func (*Chunk) CloneMessageVT ¶
func (m *Chunk) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Chunk) EqualMessageVT ¶
func (*Chunk) GetEncoding ¶
func (x *Chunk) GetEncoding() ChunkEncoding
func (*Chunk) GetMaxTime ¶
func (*Chunk) GetMinTime ¶
func (*Chunk) MarshalJSON ¶
MarshalJSON marshals the Chunk to JSON.
func (*Chunk) MarshalProtoJSON ¶
func (x *Chunk) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Chunk message to JSON.
func (*Chunk) MarshalProtoText ¶
func (*Chunk) MarshalToSizedBufferVT ¶
func (*Chunk) ProtoMessage ¶
func (*Chunk) ProtoMessage()
func (*Chunk) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Chunk from JSON.
func (*Chunk) UnmarshalProtoJSON ¶
func (x *Chunk) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Chunk message from JSON.
func (*Chunk) UnmarshalVT ¶
type ChunkEncoding ¶
type ChunkEncoding int32
ChunkEncoding identifies how a Chunk encodes its samples.
const ( // CHUNK_ENCODING_UNKNOWN is the zero value; a stored chunk never carries it. ChunkEncoding_CHUNK_ENCODING_UNKNOWN ChunkEncoding = 0 // CHUNK_ENCODING_XOR is the Prometheus XOR float chunk of tsdb/chunkenc. ChunkEncoding_CHUNK_ENCODING_XOR ChunkEncoding = 1 )
func (ChunkEncoding) Enum ¶
func (x ChunkEncoding) Enum() *ChunkEncoding
func (ChunkEncoding) MarshalJSON ¶
func (x ChunkEncoding) MarshalJSON() ([]byte, error)
MarshalJSON marshals the ChunkEncoding to JSON.
func (ChunkEncoding) MarshalProtoJSON ¶
func (x ChunkEncoding) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the ChunkEncoding to JSON.
func (ChunkEncoding) MarshalProtoText ¶
func (x ChunkEncoding) MarshalProtoText() string
func (ChunkEncoding) MarshalText ¶
func (x ChunkEncoding) MarshalText() ([]byte, error)
MarshalText marshals the ChunkEncoding to text.
func (ChunkEncoding) String ¶
func (x ChunkEncoding) String() string
func (*ChunkEncoding) UnmarshalJSON ¶
func (x *ChunkEncoding) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the ChunkEncoding from JSON.
func (*ChunkEncoding) UnmarshalProtoJSON ¶
func (x *ChunkEncoding) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the ChunkEncoding from JSON.
func (*ChunkEncoding) UnmarshalText ¶
func (x *ChunkEncoding) UnmarshalText(b []byte) error
UnmarshalText unmarshals the ChunkEncoding from text.
type CommitStats ¶
type CommitStats struct {
// Segments is the number of segments written, one per store with samples.
Segments int
// Samples is the number of samples in the written segments.
Samples int
// Blocks is the number of encoded blocks the transaction submitted for
// storage, including key-value tree nodes and the World's own blocks.
Blocks uint64
// Bytes is the number of encoded bytes of those blocks.
Bytes uint64
}
CommitStats reports what one commit wrote.
func CommitStores ¶
CommitStores writes each store's open window as one segment, and moves every target's root, in one World transaction. It writes nothing for a store without samples, and returns zero stats when no store has any.
A write holds only the window's samples and the key-value tree nodes on the path to the new keys, so its size follows the window, not the target's history. If the transaction fails, no store changes: the next commit retries the same windows first. A store whose commit is still running makes CommitStores return ErrCommitInProgress without writing. A store whose target another writer has taken over writes nothing and stands down, as Store.Lost reports; the others commit.
type Config ¶
type Config struct {
// CommitWindowMs is how long a Device collects its targets' scrapes before
// committing them in one World transaction. Zero commits every minute.
CommitWindowMs uint32 `protobuf:"varint,1,opt,name=commit_window_ms,json=commitWindowMs,proto3" json:"commitWindowMs,omitempty"`
// contains filtered or unexported fields
}
Config configures the Prometheus plugin controller.
func (*Config) CloneMessageVT ¶
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) CommitWindow ¶
CommitWindow returns the time between a Device's commits in one Space.
func (*Config) EqualMessageVT ¶
func (*Config) EqualsConfig ¶
EqualsConfig checks if the config is equal to another.
func (*Config) GetCommitWindowMs ¶
func (*Config) GetConfigID ¶
GetConfigID returns the unique string for this configuration type.
func (*Config) MarshalJSON ¶
MarshalJSON marshals the Config to JSON.
func (*Config) MarshalProtoJSON ¶
func (x *Config) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Config message to JSON.
func (*Config) MarshalProtoText ¶
func (*Config) MarshalToSizedBufferVT ¶
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Config from JSON.
func (*Config) UnmarshalProtoJSON ¶
func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Config message from JSON.
func (*Config) UnmarshalVT ¶
type Controller ¶
type Controller struct {
*bus.BusController[*Config]
// Holder publishes the registrations and reports when they are ready.
*s4wave_plugin_registration.Holder
// contains filtered or unexported fields
}
Controller registers prom/target and prom/dashboard with the core plugin and serves its resources.
func (*Controller) Execute ¶
func (c *Controller) Execute(ctx context.Context) error
Execute registers the plugin's ObjectTypes with the core plugin until ctx ends.
func (*Controller) HandleDirective ¶
func (c *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)
HandleDirective serves the plugin's resource service.
type Querier ¶
type Querier struct {
// contains filtered or unexported fields
}
Querier is a storage.Querier over a Queryable for one time range.
Select reads only the segments that overlap the range. Label lookups ignore time and report the labels of every committed series that matches.
func NewQuerier ¶
NewQuerier constructs a querier for samples between mint and maxt.
func (*Querier) LabelNames ¶
func (q *Querier) LabelNames(ctx context.Context, _ *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
LabelNames returns the sorted label names of the series matching matchers.
func (*Querier) LabelValues ¶
func (q *Querier) LabelValues(ctx context.Context, name string, _ *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
LabelValues returns the sorted values of label name among the series matching matchers.
func (*Querier) Select ¶
func (q *Querier) Select(ctx context.Context, _ bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet
Select returns the series matching matchers, sorted by labels. Series from several targets with the same labels are merged. A hints range inside the querier's range narrows the segments read.
type Queryable ¶
type Queryable struct {
// contains filtered or unexported fields
}
Queryable is a storage.Queryable over the committed segments of several targets. It reads the World and keeps no state of its own, so it sees every commit the engine has and works against a synced copy of the World.
func NewQueryable ¶
func NewQueryable(eng world.Engine, targets TargetLister) *Queryable
NewQueryable constructs a queryable over the targets that targets lists.
type Segment ¶
type Segment struct {
// MinTime is the earliest sample timestamp in milliseconds, inclusive.
MinTime int64 `protobuf:"varint,1,opt,name=min_time,json=minTime,proto3" json:"minTime,omitempty"`
// MaxTime is the latest sample timestamp in milliseconds, inclusive.
MaxTime int64 `protobuf:"varint,2,opt,name=max_time,json=maxTime,proto3" json:"maxTime,omitempty"`
// Series holds the window's samples per series in series number order.
Series []*SeriesChunks `protobuf:"bytes,3,rep,name=series,proto3" json:"series,omitempty"`
// contains filtered or unexported fields
}
Segment is the immutable samples one commit window collected. Segments of one target do not overlap in time.
func (*Segment) CloneMessageVT ¶
func (m *Segment) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Segment) EqualMessageVT ¶
func (*Segment) GetMaxTime ¶
func (*Segment) GetMinTime ¶
func (*Segment) GetSeries ¶
func (x *Segment) GetSeries() []*SeriesChunks
func (*Segment) MarshalJSON ¶
MarshalJSON marshals the Segment to JSON.
func (*Segment) MarshalProtoJSON ¶
func (x *Segment) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Segment message to JSON.
func (*Segment) MarshalProtoText ¶
func (*Segment) MarshalToSizedBufferVT ¶
func (*Segment) ProtoMessage ¶
func (*Segment) ProtoMessage()
func (*Segment) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Segment from JSON.
func (*Segment) UnmarshalProtoJSON ¶
func (x *Segment) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Segment message from JSON.
func (*Segment) UnmarshalVT ¶
type SeriesChunks ¶
type SeriesChunks struct {
// Series is the series number in the target's series table.
Series uint64 `protobuf:"varint,1,opt,name=series,proto3" json:"series,omitempty"`
// Chunks are the series' chunks in ascending time order.
Chunks []*Chunk `protobuf:"bytes,2,rep,name=chunks,proto3" json:"chunks,omitempty"`
// contains filtered or unexported fields
}
SeriesChunks holds one series' chunks within a segment.
func (*SeriesChunks) CloneMessageVT ¶
func (m *SeriesChunks) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*SeriesChunks) CloneVT ¶
func (m *SeriesChunks) CloneVT() *SeriesChunks
func (*SeriesChunks) EqualMessageVT ¶
func (this *SeriesChunks) EqualMessageVT(thatMsg any) bool
func (*SeriesChunks) EqualVT ¶
func (this *SeriesChunks) EqualVT(that *SeriesChunks) bool
func (*SeriesChunks) GetChunks ¶
func (x *SeriesChunks) GetChunks() []*Chunk
func (*SeriesChunks) GetSeries ¶
func (x *SeriesChunks) GetSeries() uint64
func (*SeriesChunks) MarshalJSON ¶
func (x *SeriesChunks) MarshalJSON() ([]byte, error)
MarshalJSON marshals the SeriesChunks to JSON.
func (*SeriesChunks) MarshalProtoJSON ¶
func (x *SeriesChunks) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the SeriesChunks message to JSON.
func (*SeriesChunks) MarshalProtoText ¶
func (x *SeriesChunks) MarshalProtoText() string
func (*SeriesChunks) MarshalToSizedBufferVT ¶
func (m *SeriesChunks) MarshalToSizedBufferVT(dAtA []byte) (int, error)
func (*SeriesChunks) MarshalToVT ¶
func (m *SeriesChunks) MarshalToVT(dAtA []byte) (int, error)
func (*SeriesChunks) MarshalVT ¶
func (m *SeriesChunks) MarshalVT() (dAtA []byte, err error)
func (*SeriesChunks) ProtoMessage ¶
func (*SeriesChunks) ProtoMessage()
func (*SeriesChunks) Reset ¶
func (x *SeriesChunks) Reset()
func (*SeriesChunks) SizeVT ¶
func (m *SeriesChunks) SizeVT() (n int)
func (*SeriesChunks) String ¶
func (x *SeriesChunks) String() string
func (*SeriesChunks) UnmarshalJSON ¶
func (x *SeriesChunks) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the SeriesChunks from JSON.
func (*SeriesChunks) UnmarshalProtoJSON ¶
func (x *SeriesChunks) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the SeriesChunks message from JSON.
func (*SeriesChunks) UnmarshalVT ¶
func (m *SeriesChunks) UnmarshalVT(dAtA []byte) error
type SeriesPage ¶
type SeriesPage struct {
// FirstSeries is the series number of the first entry. Numbers are dense and
// never reused, so the page covers FirstSeries through
// FirstSeries + len(series) - 1.
FirstSeries uint64 `protobuf:"varint,1,opt,name=first_series,json=firstSeries,proto3" json:"firstSeries,omitempty"`
// Series holds the label sets of the added series in series number order.
Series []*prom.LabelSet `protobuf:"bytes,2,rep,name=series,proto3" json:"series,omitempty"`
// contains filtered or unexported fields
}
SeriesPage appends series to a target's series table. A commit writes a page only when its window introduced series.
func (*SeriesPage) CloneMessageVT ¶
func (m *SeriesPage) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*SeriesPage) CloneVT ¶
func (m *SeriesPage) CloneVT() *SeriesPage
func (*SeriesPage) EqualMessageVT ¶
func (this *SeriesPage) EqualMessageVT(thatMsg any) bool
func (*SeriesPage) EqualVT ¶
func (this *SeriesPage) EqualVT(that *SeriesPage) bool
func (*SeriesPage) GetFirstSeries ¶
func (x *SeriesPage) GetFirstSeries() uint64
func (*SeriesPage) GetSeries ¶
func (x *SeriesPage) GetSeries() []*prom.LabelSet
func (*SeriesPage) MarshalJSON ¶
func (x *SeriesPage) MarshalJSON() ([]byte, error)
MarshalJSON marshals the SeriesPage to JSON.
func (*SeriesPage) MarshalProtoJSON ¶
func (x *SeriesPage) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the SeriesPage message to JSON.
func (*SeriesPage) MarshalProtoText ¶
func (x *SeriesPage) MarshalProtoText() string
func (*SeriesPage) MarshalToSizedBufferVT ¶
func (m *SeriesPage) MarshalToSizedBufferVT(dAtA []byte) (int, error)
func (*SeriesPage) MarshalToVT ¶
func (m *SeriesPage) MarshalToVT(dAtA []byte) (int, error)
func (*SeriesPage) MarshalVT ¶
func (m *SeriesPage) MarshalVT() (dAtA []byte, err error)
func (*SeriesPage) ProtoMessage ¶
func (*SeriesPage) ProtoMessage()
func (*SeriesPage) Reset ¶
func (x *SeriesPage) Reset()
func (*SeriesPage) SizeVT ¶
func (m *SeriesPage) SizeVT() (n int)
func (*SeriesPage) String ¶
func (x *SeriesPage) String() string
func (*SeriesPage) UnmarshalJSON ¶
func (x *SeriesPage) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the SeriesPage from JSON.
func (*SeriesPage) UnmarshalProtoJSON ¶
func (x *SeriesPage) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the SeriesPage message from JSON.
func (*SeriesPage) UnmarshalVT ¶
func (m *SeriesPage) UnmarshalVT(dAtA []byte) error
type SeriesSet ¶
type SeriesSet struct {
// contains filtered or unexported fields
}
SeriesSet is a storage.SeriesSet over series held in memory.
func NewSeriesSet ¶
NewSeriesSet constructs a series set that returns series in order.
func (*SeriesSet) Warnings ¶
func (s *SeriesSet) Warnings() annotations.Annotations
Warnings returns no warnings.
type SeriesTable ¶
type SeriesTable struct {
// contains filtered or unexported fields
}
SeriesTable maps the label sets of a target's series to dense series numbers. A number is the index of the label set in the table, is never reused, and is what segments store in place of the labels.
A SeriesTable is not safe for concurrent use.
func NewSeriesTable ¶
func NewSeriesTable() *SeriesTable
NewSeriesTable constructs an empty series table.
func (*SeriesTable) Add ¶
func (t *SeriesTable) Add(lset labels.Labels) uint64
Add appends lset as the next series and returns its number. The caller checks Lookup first; Add does not look for duplicates.
func (*SeriesTable) Labels ¶
func (t *SeriesTable) Labels(num uint64) labels.Labels
Labels returns the label set of series num.
func (*SeriesTable) LabelsFrom ¶
func (t *SeriesTable) LabelsFrom(from uint64) []labels.Labels
LabelsFrom returns the label sets from series number from to the end.
func (*SeriesTable) Len ¶
func (t *SeriesTable) Len() uint64
Len returns the number of series in the table.
func (*SeriesTable) Lookup ¶
func (t *SeriesTable) Lookup(lset labels.Labels) (uint64, bool)
Lookup returns the series number of lset.
func (*SeriesTable) Truncate ¶
func (t *SeriesTable) Truncate(n uint64)
Truncate drops the series numbered n and above.
type StaticTargets ¶
type StaticTargets []string
StaticTargets is a TargetLister with a fixed list of object keys.
func (StaticTargets) ListTargets ¶
func (t StaticTargets) ListTargets(context.Context) ([]string, error)
ListTargets returns the fixed object keys.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the single writer of one target's samples.
The target is a World object whose root is a block-backed key-value tree. The Store keeps the open window and the target's series table in memory; Append adds to the window and CommitStores writes the window as one segment. A crash or Rollback loses only the uncommitted window. Exactly one Store writes a target, so a Store reads the tree after it opens only to maintain its segments and to check that it is still the writer: the commit that closes a CompactSpan bucket drops expired segments and merges the closed buckets' segments in the same transaction, and a commit that finds a status this Store did not write stands the Store down instead of writing.
func CreateStore ¶
func CreateStore(ctx context.Context, eng world.Engine, key string, target labels.Labels) (*Store, error)
CreateStore creates the World object key as an empty target carrying the labels target on every series, and returns its writer.
func OpenStore ¶
OpenStore opens the existing target key for writing, reading its labels, series table and latest committed time.
func (*Store) Append ¶
Append adds a sample of the series lset to the open window.
lset must not carry a name that the target's labels set. The timestamp must be later than every sample the target has committed or is committing, and later than the series' earlier samples in the open window; otherwise Append returns storage.ErrOutOfOrderSample, or storage.ErrDuplicateSampleForTimestamp for the same time with another value.
func (*Store) AppendStale ¶
AppendStale adds a stale marker for the series lset at time t, which tells PromQL the series ended, as Prometheus does for a failed or vanished scrape.
func (*Store) Lost ¶
func (s *Store) Lost() <-chan struct{}
Lost returns a channel closed when a commit finds that another writer wrote the target's status since this Store opened it. A lost Store writes nothing more; the writer reopens the target to write again.
func (*Store) Rollback ¶
Rollback discards every uncommitted sample and the series only they introduced. It returns ErrCommitInProgress while a commit is running.
func (*Store) SetStatus ¶
func (s *Store) SetStatus(status *s4wave_prom.TargetStatus) error
SetStatus records status to commit with the next window that holds samples. A later call replaces an uncommitted status.
type StoreReader ¶
type StoreReader struct {
// contains filtered or unexported fields
}
StoreReader reads one target's key-value tree: its labels, series table and segments. It holds no state beyond the transaction, which the caller discards.
func NewStoreReader ¶
func NewStoreReader(kv kvtx.Tx) *StoreReader
NewStoreReader constructs a reader over a transaction on a target's tree.
func (*StoreReader) ForEachSegment ¶
func (r *StoreReader) ForEachSegment(ctx context.Context, mint, maxt int64, fn func(*Segment) error) error
ForEachSegment calls fn with each segment overlapping mint to maxt inclusive, in time order. Segment keys carry the time range, so a segment outside the range is not read.
func (*StoreReader) Labels ¶
func (r *StoreReader) Labels(ctx context.Context, matchers []*labels.Matcher) ([]labels.Labels, error)
Labels returns the full label sets of the target's series matching matchers, ignoring time.
func (*StoreReader) LastSegmentMaxTime ¶
LastSegmentMaxTime returns the latest sample time the target has committed. It returns false when the target has no segment.
func (*StoreReader) Meta ¶
func (r *StoreReader) Meta(ctx context.Context) (*s4wave_prom.TargetMeta, error)
Meta returns the target's TargetMeta.
func (*StoreReader) Select ¶
func (r *StoreReader) Select(ctx context.Context, mint, maxt int64, matchers []*labels.Matcher) ([]storage.Series, error)
Select returns the target's series matching matchers, with their samples in mint to maxt. The target's labels are added to every series. The series are not sorted.
func (*StoreReader) Table ¶
func (r *StoreReader) Table(ctx context.Context) (*SeriesTable, error)
Table reads the target's series table from its series pages.
func (*StoreReader) TargetLabels ¶
TargetLabels returns the labels every series of the target carries.
type TargetLister ¶
type TargetLister interface {
// ListTargets returns the object keys of the targets to query. A key whose
// object does not exist is skipped by the query.
ListTargets(ctx context.Context) ([]string, error)
}
TargetLister lists the World object keys of the targets a Queryable reads. The Space's set of prom/target objects is the list; a lister is where that set comes from.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window collects the samples one commit appends, per series, in XOR chunks.
A window holds only samples that are not yet committed, so the bytes a commit writes follow the window, not the history of the series. A Window is not safe for concurrent use; the Store that owns it serializes access.
func NewWindow ¶
NewWindow constructs an empty window. firstSeries is the number the next new series of the target's series table will get.
func (*Window) Append ¶
Append adds a sample of series num.
Timestamps of one series must increase. Repeating the latest timestamp with the same value is accepted and ignored, as Prometheus does. Repeating it with another value returns storage.ErrDuplicateSampleForTimestamp, and an earlier timestamp returns storage.ErrOutOfOrderSample.
func (*Window) FirstSeries ¶
FirstSeries returns the number of the first series the window introduced.
Source Files
¶
- chunk-series.go
- commit-group.go
- commit-stats.go
- commit.go
- compact.go
- config.go
- config.pb.go
- controller.go
- dashboard.go
- errors.go
- handler.go
- keys.go
- label-set.go
- process.go
- prom.pb.go
- querier.go
- query.go
- queryable.go
- scrape-gather.go
- scrape-http.go
- scrape.go
- series-set.go
- series-table.go
- store-reader.go
- store.go
- target-lister.go
- watch-targets.go
- watch.go
- window.go