Documentation ¶
Index ¶
- Constants
- Variables
- func GetShuffleShardingSubring(ring ring.ReadRing, tenantID string, limits Limits) ring.ReadRing
- type Config
- type Gateway
- func (g *Gateway) GetChunkRef(ctx context.Context, req *logproto.GetChunkRefRequest) (*logproto.GetChunkRefResponse, error)
- func (g *Gateway) GetSeries(ctx context.Context, req *logproto.GetSeriesRequest) (*logproto.GetSeriesResponse, error)
- func (g *Gateway) GetStats(ctx context.Context, req *logproto.IndexStatsRequest) (*logproto.IndexStatsResponse, error)
- func (g *Gateway) GetVolume(ctx context.Context, req *logproto.VolumeRequest) (*logproto.VolumeResponse, error)
- func (g *Gateway) LabelNamesForMetricName(ctx context.Context, req *logproto.LabelNamesForMetricNameRequest) (*logproto.LabelResponse, error)
- func (g *Gateway) LabelValuesForMetricName(ctx context.Context, req *logproto.LabelValuesForMetricNameRequest) (*logproto.LabelResponse, error)
- func (g *Gateway) QueryIndex(request *logproto.QueryIndexRequest, ...) error
- type IndexClient
- type IndexClientWithRange
- type IndexQuerier
- type Limits
- type ManagerMode
- type Mode
- type NoopStrategy
- type RingCfg
- type RingManager
- func (rm *RingManager) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc)
- func (rm *RingManager) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, _ string, ...) (ring.InstanceState, ring.Tokens)
- func (rm *RingManager) OnRingInstanceStopping(_ *ring.BasicLifecycler)
- func (rm *RingManager) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens)
- func (rm *RingManager) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type ServerInterceptors
- type ShardingStrategy
- type ShuffleShardingStrategy
Constants ¶
const ( // RingIdentifier is used as a unique name to register the Index Gateway ring. RingIdentifier = "index-gateway" // RingKey is the name of the key used to register the different Index Gateway instances in the key-value store. RingKey = "index-gateway" )
Variables ¶
var ( // IndexesSync is the operation used to check the authoritative owners of an index // (replicas included). IndexesSync = ring.NewOp([]ring.InstanceState{ring.JOINING, ring.ACTIVE, ring.LEAVING}, nil) // IndexesRead is the operation run by the querier/query frontent to query // indexes via the index gateway. IndexesRead = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, nil) )
Functions ¶
func GetShuffleShardingSubring ¶
GetShuffleShardingSubring returns the subring to be used for a given user. This function should be used both by index gateway servers and clients in order to guarantee the same logic is used.
Types ¶
type Config ¶
type Config struct { // Mode configures in which mode the client will be running when querying and communicating with an Index Gateway instance. Mode Mode `yaml:"mode"` // Ring configures the ring key-value store used to save and retrieve the different Index Gateway instances. // // In case it isn't explicitly set, it follows the same behavior of the other rings (ex: using the common configuration // section and the ingester configuration by default). Ring RingCfg `` /* 272-byte string literal not displayed */ }
Config configures an Index Gateway server.
func (*Config) RegisterFlags ¶
RegisterFlags register all IndexGatewayClientConfig flags and all the flags of its subconfigs but with a prefix (ex: shipper).
type Gateway ¶
func NewIndexGateway ¶
func NewIndexGateway(cfg Config, log log.Logger, _ prometheus.Registerer, indexQuerier IndexQuerier, indexClients []IndexClientWithRange) (*Gateway, error)
NewIndexGateway instantiates a new Index Gateway and start its services.
In case it is configured to be in ring mode, a Basic Service wrapping the ring client is started. Otherwise, it starts an Idle Service that doesn't have lifecycle hooks.
func (*Gateway) GetChunkRef ¶
func (g *Gateway) GetChunkRef(ctx context.Context, req *logproto.GetChunkRefRequest) (*logproto.GetChunkRefResponse, error)
func (*Gateway) GetSeries ¶
func (g *Gateway) GetSeries(ctx context.Context, req *logproto.GetSeriesRequest) (*logproto.GetSeriesResponse, error)
func (*Gateway) GetStats ¶
func (g *Gateway) GetStats(ctx context.Context, req *logproto.IndexStatsRequest) (*logproto.IndexStatsResponse, error)
func (*Gateway) GetVolume ¶
func (g *Gateway) GetVolume(ctx context.Context, req *logproto.VolumeRequest) (*logproto.VolumeResponse, error)
func (*Gateway) LabelNamesForMetricName ¶
func (g *Gateway) LabelNamesForMetricName(ctx context.Context, req *logproto.LabelNamesForMetricNameRequest) (*logproto.LabelResponse, error)
func (*Gateway) LabelValuesForMetricName ¶
func (g *Gateway) LabelValuesForMetricName(ctx context.Context, req *logproto.LabelValuesForMetricNameRequest) (*logproto.LabelResponse, error)
func (*Gateway) QueryIndex ¶
func (g *Gateway) QueryIndex(request *logproto.QueryIndexRequest, server logproto.IndexGateway_QueryIndexServer) error
type IndexClient ¶
type IndexClient interface { seriesindex.ReadClient Stop() }
type IndexClientWithRange ¶
type IndexClientWithRange struct { IndexClient TableRange config.TableRange }
type IndexQuerier ¶
type IndexQuerier interface { stores.ChunkFetcher index.BaseReader Stop() }
type ManagerMode ¶
type ManagerMode int
ManagerMode defines the different modes for the RingManager to execute.
The RingManager and its modes are only relevant if the IndexGateway is running in ring mode.
const ( // ClientMode is the RingManager mode executed by Loki components that are clients of the IndexGateway. // The RingManager in client will have its own ring key-value store but it won't try to register itself in the ring. ClientMode ManagerMode = iota // ServerMode is the RingManager mode execute by the IndexGateway. // The RingManager in server mode will register itself in the ring. ServerMode )
type Mode ¶
type Mode string
Mode represents in which mode an Index Gateway instance is running.
Right now, two modes are supported: simple mode (default) and ring mode.
const ( // SimpleMode is a mode where an Index Gateway instance solely handle all the work. SimpleMode Mode = "simple" // RingMode is a mode where different Index Gateway instances are assigned to handle different tenants. // // It is more horizontally scalable than the simple mode, but requires running a key-value store ring. RingMode Mode = "ring" )
type NoopStrategy ¶
type NoopStrategy struct{}
NoopStrategy is an implementation of the ShardingStrategy that does not filter anything. This is used when the index gateway runs in simple mode or when the index gateway runs in ring mode, but the ring manager runs in client mode.
func NewNoopStrategy ¶
func NewNoopStrategy() *NoopStrategy
func (*NoopStrategy) FilterTenants ¶
func (s *NoopStrategy) FilterTenants(tenantIDs []string) ([]string, error)
FilterTenants implements ShardingStrategy.
type RingCfg ¶
type RingCfg struct { // InternalRingCfg configures the Index Gateway ring. loki_util.RingConfig `yaml:",inline"` // ReplicationFactor defines how many Index Gateway instances are assigned to each tenant. // // Whenever the store queries the ring key-value store for the Index Gateway instance responsible for tenant X, // multiple Index Gateway instances are expected to be returned as Index Gateway might be busy/locked for specific // reasons (this is assured by the spikey behavior of Index Gateway latencies). ReplicationFactor int `yaml:"replication_factor"` }
RingCfg is a wrapper for our Index Gateway ring configuration plus the replication factor.
type RingManager ¶
type RingManager struct { services.Service RingLifecycler *ring.BasicLifecycler Ring *ring.Ring Mode ManagerMode // contains filtered or unexported fields }
RingManager is a component instantiated before all the others and is responsible for the ring setup.
All Loki components that are involved with the IndexGateway (including the IndexGateway itself) will require a RingManager. However, the components that are clients of the IndexGateway will ran it in client mode while the IndexGateway itself will ran the manager in server mode.
func NewRingManager ¶
func NewRingManager(mode ManagerMode, cfg Config, log log.Logger, registerer prometheus.Registerer) (*RingManager, error)
NewRingManager is the recommended way of instantiating a RingManager.
The other functions will assume the RingManager was instantiated through this function.
func (*RingManager) OnRingInstanceHeartbeat ¶
func (rm *RingManager) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc)
func (*RingManager) OnRingInstanceRegister ¶
func (rm *RingManager) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, _ string, instanceDesc ring.InstanceDesc) (ring.InstanceState, ring.Tokens)
func (*RingManager) OnRingInstanceStopping ¶
func (rm *RingManager) OnRingInstanceStopping(_ *ring.BasicLifecycler)
func (*RingManager) OnRingInstanceTokens ¶
func (rm *RingManager) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens)
func (*RingManager) ServeHTTP ¶
func (rm *RingManager) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP serves the HTTP route /indexgateway/ring.
type ServerInterceptors ¶
type ServerInterceptors struct { PerTenantRequestCount grpc.UnaryServerInterceptor // contains filtered or unexported fields }
func NewServerInterceptors ¶
func NewServerInterceptors(r prometheus.Registerer) *ServerInterceptors
type ShardingStrategy ¶
type ShardingStrategy interface { // FilterTenants whose indexes should be loaded by the index gateway. // Returns the list of user IDs that should be synced by the index gateway. FilterTenants(tenantID []string) ([]string, error) }
func GetShardingStrategy ¶
func GetShardingStrategy(cfg Config, indexGatewayRingManager *RingManager, o Limits) ShardingStrategy
GetShardingStrategy returns the correct ShardingStrategy implementation based on provided configuration.
type ShuffleShardingStrategy ¶
type ShuffleShardingStrategy struct {
// contains filtered or unexported fields
}
func NewShuffleShardingStrategy ¶
func NewShuffleShardingStrategy(r ring.ReadRing, l Limits, instanceAddr, instanceID string) *ShuffleShardingStrategy
func (*ShuffleShardingStrategy) FilterTenants ¶
func (s *ShuffleShardingStrategy) FilterTenants(tenantIDs []string) ([]string, error)
FilterTenants implements ShardingStrategy.