elastic

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ElasticTimeWindowDelay is the time buffer to allow logs to come in before we try to serve
	// them up. We do this to not miss later logs when using search_after the way we do.
	ElasticTimeWindowDelay = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Elastic

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

Elastic is an interface around an elasticsearch client that abstracts away common queries and indexing operations.

func Setup

func Setup(conf model.ElasticLoggingConfig) (*Elastic, error)

Setup sets up a new elasticsearch client with the given configuration.

func (*Elastic) AddTaskLogs

func (e *Elastic) AddTaskLogs(logs []*model.TaskLog) error

AddTaskLogs indexes a batch of tasks logs into the index like tasklogs-yyyy-MM-dd based on the UTC value of their timestamp.

func (*Elastic) DeleteTaskLogs

func (e *Elastic) DeleteTaskLogs(ids []model.TaskID) error

DeleteTaskLogs deletes the logs for the given tasks.

func (*Elastic) DeleteTrialLogs

func (e *Elastic) DeleteTrialLogs(ids []int) error

DeleteTrialLogs deletes the logs for the given trial IDs.

func (*Elastic) MaxTerminationDelay

func (e *Elastic) MaxTerminationDelay() time.Duration

MaxTerminationDelay is the max delay before a consumer can be sure all logs have been recevied. For Elasticsearch, this _must_ be greater than internal/elastic.elasticTimeWindowDelay or else following terminates before all logs are delivered.

func (*Elastic) TaskLogs

func (e *Elastic) TaskLogs(
	taskID model.TaskID, limit int, fs []api.Filter, order apiv1.OrderBy,
	searchAfter interface{},
) ([]*model.TaskLog, interface{}, error)

TaskLogs return a set of logs matching the provided criteria from the task. This uses the search after API, since from+size is prohibitively expensive for deep pagination and the scroll api specifically recommends search after over itself. https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-search-after.html

func (*Elastic) TaskLogsCount

func (e *Elastic) TaskLogsCount(taskID model.TaskID, fs []api.Filter) (int, error)

TaskLogsCount returns the number of logs for the given task.

func (*Elastic) TaskLogsFields

func (e *Elastic) TaskLogsFields(taskID model.TaskID) (*apiv1.TaskLogsFieldsResponse, error)

TaskLogsFields returns the unique fields that can be filtered on for the given task.

func (*Elastic) TrialLogs

func (e *Elastic) TrialLogs(
	trialID, limit int, fs []api.Filter, order apiv1.OrderBy, searchAfter interface{},
) ([]*model.TrialLog, interface{}, error)

TrialLogs return a set of trial logs within a specified window. This uses the search after API, since from+size is prohibitively expensive for deep pagination and the scroll api specifically recommends search after over itself. https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-search-after.html

func (*Elastic) TrialLogsCount

func (e *Elastic) TrialLogsCount(trialID int, fs []api.Filter) (int, error)

TrialLogsCount returns the number of trial logs for the given trial.

func (*Elastic) TrialLogsFields

func (e *Elastic) TrialLogsFields(trialID int) (*apiv1.TrialLogsFieldsResponse, error)

TrialLogsFields returns the unique fields that can be filtered on for the given trial.

Jump to

Keyboard shortcuts

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