receive

package
v0.22.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 55 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultTenantHeader is the default header used to designate the tenant making a write request.
	DefaultTenantHeader = "THANOS-TENANT"
	// DefaultTenant is the default value used for when no tenant is passed via the tenant header.
	DefaultTenant = "default-tenant"
	// DefaultTenantLabel is the default label-name used for when no tenant is passed via the tenant header.
	DefaultTenantLabel = "tenant_id"
	// DefaultReplicaHeader is the default header used to designate the replica count of a write request.
	DefaultReplicaHeader = "THANOS-REPLICA"
)

Variables

View Source
var ErrNotReady = errors.New("TSDB not ready")

ErrNotReady is returned if the underlying storage is not ready yet.

Functions

func HashringFromConfigWatcher added in v0.18.0

func HashringFromConfigWatcher(ctx context.Context, updates chan<- Hashring, cw *ConfigWatcher) error

HashringFromConfigWatcher creates multi-tenant hashrings from a hashring configuration file watcher. The configuration file is watched for updates. Hashrings are returned on the updates channel. Which hashring to use for a tenant is determined by the tenants field of the hashring configuration. The updates chan is closed before exiting.

Types

type Appendable

type Appendable interface {
	Appender(ctx context.Context) (storage.Appender, error)
}

Appendable returns an Appender.

type ConfigWatcher

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

ConfigWatcher is able to watch a file containing a hashring configuration for updates.

func NewConfigWatcher

func NewConfigWatcher(logger log.Logger, reg prometheus.Registerer, path string, interval model.Duration) (*ConfigWatcher, error)

NewConfigWatcher creates a new ConfigWatcher.

func (*ConfigWatcher) C

func (cw *ConfigWatcher) C() <-chan []HashringConfig

C returns a chan that gets hashring configuration updates.

func (*ConfigWatcher) Run

func (cw *ConfigWatcher) Run(ctx context.Context)

Run starts the ConfigWatcher until the given context is canceled.

func (*ConfigWatcher) Stop added in v0.15.0

func (cw *ConfigWatcher) Stop()

Stop shuts down the config watcher.

func (*ConfigWatcher) ValidateConfig added in v0.12.0

func (cw *ConfigWatcher) ValidateConfig() error

ValidateConfig returns an error if the configuration that's being watched is not valid.

type Handler

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

Handler serves a Prometheus remote write receiving HTTP endpoint.

func NewHandler

func NewHandler(logger log.Logger, o *Options) *Handler

func (*Handler) Close

func (h *Handler) Close()

Close stops the Handler.

func (*Handler) Hashring

func (h *Handler) Hashring(hashring Hashring)

Hashring sets the hashring for the handler and marks the hashring as ready. The hashring must be set to a non-nil value in order for the handler to be ready and usable. If the hashring is nil, then the handler is marked as not ready.

func (*Handler) RemoteWrite added in v0.11.0

func (h *Handler) RemoteWrite(ctx context.Context, r *storepb.WriteRequest) (*storepb.WriteResponse, error)

RemoteWrite implements the gRPC remote write handler for storepb.WriteableStore.

func (*Handler) Run

func (h *Handler) Run() error

Run serves the HTTP endpoints.

type Hashring

type Hashring interface {
	// Get returns the first node that should handle the given tenant and time series.
	Get(tenant string, timeSeries *prompb.TimeSeries) (string, error)
	// GetN returns the nth node that should handle the given tenant and time series.
	GetN(tenant string, timeSeries *prompb.TimeSeries, n uint64) (string, error)
}

Hashring finds the correct node to handle a given time series for a specified tenant. It returns the node and any error encountered.

func HashringFromConfig

func HashringFromConfig(content string) (Hashring, error)

HashringFromConfig loads raw configuration content and returns a Hashring if the given configuration is not valid.

type HashringConfig

type HashringConfig struct {
	Hashring  string   `json:"hashring,omitempty"`
	Tenants   []string `json:"tenants,omitempty"`
	Endpoints []string `json:"endpoints"`
}

HashringConfig represents the configuration for a hashring a receive node knows about.

type MultiTSDB added in v0.13.0

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

func NewMultiTSDB added in v0.13.0

func NewMultiTSDB(
	dataDir string,
	l log.Logger,
	reg prometheus.Registerer,
	tsdbOpts *tsdb.Options,
	labels labels.Labels,
	tenantLabelName string,
	bucket objstore.Bucket,
	allowOutOfOrderUpload bool,
	hashFunc metadata.HashFunc,
) *MultiTSDB

NewMultiTSDB creates new MultiTSDB. NOTE: Passed labels has to be sorted by name.

func (*MultiTSDB) Close added in v0.14.0

func (t *MultiTSDB) Close() error

func (*MultiTSDB) Flush added in v0.13.0

func (t *MultiTSDB) Flush() error

func (*MultiTSDB) Open added in v0.13.0

func (t *MultiTSDB) Open() error

func (*MultiTSDB) RemoveLockFilesIfAny added in v0.15.0

func (t *MultiTSDB) RemoveLockFilesIfAny() error

func (*MultiTSDB) Sync added in v0.13.0

func (t *MultiTSDB) Sync(ctx context.Context) (int, error)

func (*MultiTSDB) TSDBExemplars added in v0.22.0

func (t *MultiTSDB) TSDBExemplars() map[string]*exemplars.TSDB

func (*MultiTSDB) TSDBStores added in v0.13.0

func (t *MultiTSDB) TSDBStores() map[string]storepb.StoreServer

func (*MultiTSDB) TenantAppendable added in v0.13.0

func (t *MultiTSDB) TenantAppendable(tenantID string) (Appendable, error)

type Options

type Options struct {
	Writer            *Writer
	ListenAddress     string
	Registry          prometheus.Registerer
	TenantHeader      string
	DefaultTenantID   string
	ReplicaHeader     string
	Endpoint          string
	ReplicationFactor uint64
	ReceiverMode      ReceiverMode
	Tracer            opentracing.Tracer
	TLSConfig         *tls.Config
	DialOpts          []grpc.DialOption
	ForwardTimeout    time.Duration
}

Options for the web Handler.

type ReadyStorage added in v0.13.0

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

ReadyStorage implements the Storage interface while allowing to set the actual storage at a later point in time. TODO: Replace this with upstream Prometheus implementation when it is exposed.

func (*ReadyStorage) Appender added in v0.13.0

func (s *ReadyStorage) Appender(ctx context.Context) (storage.Appender, error)

Appender implements the Storage interface.

func (*ReadyStorage) Close added in v0.13.0

func (s *ReadyStorage) Close() error

Close implements the Storage interface.

func (*ReadyStorage) ExemplarQuerier added in v0.22.0

func (s *ReadyStorage) ExemplarQuerier(ctx context.Context) (storage.ExemplarQuerier, error)

ExemplarQuerier implements the Storage interface.

func (*ReadyStorage) Get added in v0.13.0

func (s *ReadyStorage) Get() *tsdb.DB

Get the storage.

func (*ReadyStorage) Querier added in v0.13.0

func (s *ReadyStorage) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error)

Querier implements the Storage interface.

func (*ReadyStorage) Set added in v0.13.0

func (s *ReadyStorage) Set(db *tsdb.DB)

Set the storage.

func (*ReadyStorage) StartTime added in v0.13.0

func (s *ReadyStorage) StartTime() (int64, error)

StartTime implements the Storage interface.

type ReceiverMode added in v0.22.0

type ReceiverMode string
const (
	RouterOnly     ReceiverMode = "RouterOnly"
	IngestorOnly   ReceiverMode = "IngestorOnly"
	RouterIngestor ReceiverMode = "RouterIngestor"
)

type SingleNodeHashring

type SingleNodeHashring string

SingleNodeHashring always returns the same node.

func (SingleNodeHashring) Get

func (s SingleNodeHashring) Get(tenant string, ts *prompb.TimeSeries) (string, error)

Get implements the Hashring interface.

func (SingleNodeHashring) GetN

GetN implements the Hashring interface.

type TenantStorage added in v0.13.0

type TenantStorage interface {
	TenantAppendable(string) (Appendable, error)
}

type UnRegisterer added in v0.8.0

type UnRegisterer struct {
	prometheus.Registerer
}

UnRegisterer is a Prometheus registerer that ensures that collectors can be registered by unregistering already-registered collectors. FlushableStorage uses this registerer in order to not lose metric values between DB flushes.

func (*UnRegisterer) MustRegister added in v0.8.0

func (u *UnRegisterer) MustRegister(cs ...prometheus.Collector)

type Writer

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

func NewWriter

func NewWriter(logger log.Logger, multiTSDB TenantStorage) *Writer

func (*Writer) Write added in v0.8.0

func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteRequest) error

Jump to

Keyboard shortcuts

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