Documentation
¶
Overview ¶
Package deletes implements Loki's delete API: requests are stored in ClickHouse and applied at query time by Loki's own filtering pipeline.
Index ¶
- func NewQueryClient(s *Store, l deletion.Limits, m *deletion.DeleteRequestClientMetrics, ...) deletion.DeleteRequestsClient
- type Handler
- type Processor
- type Store
- func (s *Store) Add(ctx context.Context, tenant, query string, start, end model.Time) (string, error)
- func (s *Store) Cancel(ctx context.Context, tenant, id string) error
- func (s *Store) Get(ctx context.Context, tenant, id string) (deletionproto.DeleteRequest, error)
- func (s *Store) GetAllDeleteRequestsForUser(ctx context.Context, userID string, forQuerytimeFiltering bool, ...) ([]deletionproto.DeleteRequest, error)
- func (s *Store) MarkProcessed(ctx context.Context, r deletionproto.DeleteRequest) error
- func (s *Store) Unprocessed(ctx context.Context) ([]deletionproto.DeleteRequest, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewQueryClient ¶
func NewQueryClient(s *Store, l deletion.Limits, m *deletion.DeleteRequestClientMetrics, opts ...deletion.DeleteRequestsStoreOption) deletion.DeleteRequestsClient
NewQueryClient returns the delete-requests client queries filter with: the store behind Loki's per-tenant cache (refreshed every 5 minutes) and its deletion_mode check. The stack mirrors deleteRequestsClient in grafana/loki@39c256e50a80 pkg/loki/modules.go. The caller must call Stop.
Types ¶
type Handler ¶
type Handler struct {
Store *Store
Limits deletionLimits
MaxInterval time.Duration
CancelPeriod time.Duration
}
Handler serves the delete API endpoints.
func (*Handler) Add ¶
func (h *Handler) Add(w http.ResponseWriter, r *http.Request)
Add handles addition of a new delete request.
func (*Handler) Cancel ¶
func (h *Handler) Cancel(w http.ResponseWriter, r *http.Request)
Cancel handles delete request cancellation.
type Processor ¶
type Processor struct {
Store *Store
Conn driver.Conn
DB string
Topo chstore.Topology
CancelPeriod time.Duration
Interval time.Duration
Logger log.Logger
// Now returns the "current time" for the cancel-period check (default time.Now).
Now func() time.Time
// contains filtered or unexported fields
}
Processor physically deletes delete requests that are past their cancel period. Query-time filtering already hides the matching lines; the processor makes the deletion permanent and marks the request processed (which also stops query-time filtering for it).
func (*Processor) ProcessDue ¶
ProcessDue physically deletes every received request older than CancelPeriod, then marks it processed. lightweight_deletes_sync=2 makes the rows invisible on every replica before the call returns. Requests are fault-isolated: a failing request is logged, retried on the next pass (the rows are still hidden by query-time filtering) and does not stop the others. After a pass that deleted rows it runs APPLY DELETED MASK so the rows leave the disk too; a failed mask step is retried on the next pass.
type Store ¶
type Store struct {
Conn driver.Conn
Now func() time.Time // default time.Now
// contains filtered or unexported fields
}
Store keeps delete requests in ClickHouse; it implements Loki's querier/deletion.DeleteGetter for query-time filtering.
func (*Store) Add ¶
func (s *Store) Add(ctx context.Context, tenant, query string, start, end model.Time) (string, error)
Add stores a new delete request and returns its id. The id is 8 random hex characters; Loki's format and ids differ (docs/divergences.md).
func (*Store) Cancel ¶
Cancel marks the request cancelled; cancelled requests are hidden from all reads.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, tenant, id string) (deletionproto.DeleteRequest, error)
Get returns the latest version of the request, or deletion.ErrDeleteRequestNotFound.
func (*Store) GetAllDeleteRequestsForUser ¶
func (s *Store) GetAllDeleteRequestsForUser(ctx context.Context, userID string, forQuerytimeFiltering bool, tr *deletion.TimeRange) ([]deletionproto.DeleteRequest, error)
GetAllDeleteRequestsForUser implements querier/deletion.DeleteGetter. With forQuerytimeFiltering only pending (received) requests are returned, since those are the ones a query must hide lines for; tr, when set, keeps only requests overlapping it.
func (*Store) MarkProcessed ¶
func (s *Store) MarkProcessed(ctx context.Context, r deletionproto.DeleteRequest) error
MarkProcessed records that the request has been processed.
func (*Store) Unprocessed ¶
func (s *Store) Unprocessed(ctx context.Context) ([]deletionproto.DeleteRequest, error)
Unprocessed returns every pending (received) request, all tenants.