query

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectClient

func GetObjectClient(conf loki.Config, cm storage.ClientMetrics) (chunk.ObjectClient, error)

func LoadSchemaUsingObjectClient

func LoadSchemaUsingObjectClient(oc chunk.ObjectClient, names ...string) (*config.SchemaConfig, error)

LoadSchemaUsingObjectClient returns the loaded schema from the first found object

Types

type PartFile

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

PartFile partially complete file. Expected usage:

  1. Create the temp file: CreateTemp
  2. Write the data to the file
  3. When you're done, call Finalize and the temp file will be closed and renamed

func NewPartFile

func NewPartFile(filename string) *PartFile

NewPartFile initializes a new partial file object, setting the filename which will be used when the file is closed with the Finalize function.

This will not create the file, call CreateTemp to create the file.

func (*PartFile) Close

func (f *PartFile) Close() error

Close closes the temporary file. Double close is handled gracefully without error so that Close can be deferred for errors, and is also called when Finalize is called.

func (*PartFile) CreateTempFile

func (f *PartFile) CreateTempFile() error

CreateTempFile creates the temp file to store the data before Finalize is called.

func (*PartFile) Exists

func (f *PartFile) Exists() (bool, error)

Exists checks if the completed file exists.

func (*PartFile) Finalize

func (f *PartFile) Finalize() error

Finalize closes the temporary file, and renames it to the final file name.

func (*PartFile) Write

func (f *PartFile) Write(b []byte) (int, error)

Write to the temporary file.

type Query

type Query struct {
	QueryString            string
	Start                  time.Time
	End                    time.Time
	Limit                  int
	BatchSize              int
	Forward                bool
	Step                   time.Duration
	Interval               time.Duration
	Quiet                  bool
	NoLabels               bool
	IgnoreLabelsKey        []string
	ShowLabelsKey          []string
	FixedLabelsLen         int
	ColoredOutput          bool
	LocalConfig            string
	FetchSchemaFromStorage bool

	// The duration of each part/job.
	ParallelDuration time.Duration

	// Number of workers to start.
	ParallelMaxWorkers int

	// Path prefix of the name for each part file.
	// The idea for this is to allow the user to download many different queries at the same
	// time, and/or give a directory for the part files to be placed.
	PartPathPrefix string

	// By default (false value), if the part file has finished downloading, and another job with
	// the same filename is run, it will skip the completed files. This will remove the completed
	// files as each worker gets to that part file, so the part will be downloaded again.
	OverwriteCompleted bool

	// If true, the part files will be read in order, and the data will be output to stdout.
	MergeParts bool

	// If MergeParts is false, this parameter has no effect, part files will be kept.
	// Otherwise, if this is true, the part files will not be deleted once they have been merged.
	KeepParts bool
}

Query contains all necessary fields to execute instant and range queries and print the results.

func (*Query) DoLocalQuery

func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string, useRemoteSchema bool) error

DoLocalQuery executes the query against the local store using a Loki configuration file.

func (*Query) DoQuery

func (q *Query) DoQuery(c client.Client, out output.LogOutput, statistics bool)

DoQuery executes the query and prints out the results

func (*Query) DoQueryParallel

func (q *Query) DoQueryParallel(c client.Client, out output.LogOutput, statistics bool)

func (*Query) SetInstant

func (q *Query) SetInstant(time time.Time)

SetInstant makes the Query an instant type

func (*Query) TailQuery

func (q *Query) TailQuery(delayFor time.Duration, c client.Client, out output.LogOutput)

TailQuery connects to the Loki websocket endpoint and tails logs

Jump to

Keyboard shortcuts

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