indexer

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package indexer processing logs and stores them for querying. This is probably confusing several concerns and needs work.

On start up, each indexer is assigned a new UUID. The indexer creates shards, collections of shard files that span a liited time duration (shardDuration). Each shard created by an indexer is assigned a UUID. Each incoming stream is assigned a UUID. A sharfile is created for each stream. Each message in a stream is assigned its ordinal position in the stream

The dataDir should be laid out as follows: dataDir/shardID/streamID.pb.log

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewArchive

func NewArchive(opts ...ArchiveOpt) (*shardArchive, error)

Types

type ArchiveOpt

type ArchiveOpt func(a *shardArchive) (*shardArchive, error)

func WithArchiveDataDir

func WithArchiveDataDir(datadir string) ArchiveOpt

func WithArchiveEncryptTo

func WithArchiveEncryptTo(ent []openpgp.Entity) ArchiveOpt

func WithArchiveGzipCompression

func WithArchiveGzipCompression(level int) ArchiveOpt

func WithArchiveRetention

func WithArchiveRetention(d time.Duration) ArchiveOpt

func WithArchiveStowConfig

func WithArchiveStowConfig(scfg stow.ConfigMap) ArchiveOpt

type Indexer

type Indexer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Indexer implements a queryable index for storage of logspray mssages.

func New

func New(opts ...Opt) (*Indexer, error)

New creates a new index.

func (*Indexer) AddSource

func (idx *Indexer) AddSource(ctx context.Context, id string, labels map[string]string) (sinks.MessageWriter, error)

AddSource adds a new source to the remote server

func (*Indexer) Close

func (idx *Indexer) Close() error

Close this index

func (*Indexer) Collect

func (i *Indexer) Collect(ch chan<- prometheus.Metric)

Collect implements the prom metrics collection Collector interface

func (*Indexer) Describe

func (i *Indexer) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus describe interfaces for metric collection

func (*Indexer) GrafanaAnnotations

func (idx *Indexer) GrafanaAnnotations(ctx context.Context, from, to time.Time, query string) ([]grafanasj.Annotation, error)

GrafanaAnnotations implements the grafana Simple JSON Annotations request

func (*Indexer) GrafanaQuery

func (idx *Indexer) GrafanaQuery(ctx context.Context, from, to time.Time, interval time.Duration, maxDPs int, target string) ([]grafanasj.Data, error)

GrafanaQuery implements the Grafana Simple JSON Query request

func (*Indexer) GrafanaQueryTable added in v0.2.3

func (idx *Indexer) GrafanaQueryTable(ctx context.Context, from, to time.Time, target string) ([]grafanasj.TableColumn, error)

GrafanaQueryTable implements the Grafana Simple JSON Query request for tables

func (*Indexer) GrafanaSearch

func (idx *Indexer) GrafanaSearch(ctx context.Context, target string) ([]string, error)

GrafanaSearch implements the Grafana Simple JSON search query

func (*Indexer) LabelValues

func (idx *Indexer) LabelValues(name string, from, to time.Time, count int) ([]string, int, error)

LabelValues returns all the known values for a given label.

func (*Indexer) Labels

func (idx *Indexer) Labels(from, to time.Time) ([]string, error)

Labels lists all the label names in the current index

func (*Indexer) Search

func (idx *Indexer) Search(ctx context.Context, msgFunc logspray.MessageFunc, matcher ql.MatchFunc, from, to time.Time, reverse bool) error

Search queries the index for documents matching the provided search query.

type MessageWriter

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

MessageWriter is a sinks.MessageWriter that writes to a remote server

func (*MessageWriter) Close

func (w *MessageWriter) Close() error

Close closes the remote stream.

func (*MessageWriter) WriteMessage

func (w *MessageWriter) WriteMessage(ctx context.Context, m *logspray.Message) error

WriteMessage writes a message to the log stream.

type Opt

type Opt func(i *Indexer) error

Opt defines an index option function.

func WithDataDir

func WithDataDir(d string) Opt

WithDataDir lets you set the base filesystem path to store data to.

func WithSharDuration

func WithSharDuration(d time.Duration) Opt

WithSharDuration allows you to set the time duration of a shard.

type Shard

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

Shard represents a logging session.

func (*Shard) LabelValues

func (s *Shard) LabelValues(name string) []string

LabelValues returns all the known values for a given label.

func (*Shard) Labels

func (s *Shard) Labels() []string

Labels retursn the list of labels in the label cache

func (*Shard) Search

func (s *Shard) Search(ctx context.Context, msgFunc logspray.MessageFunc, matcher ql.MatchFunc, from, to time.Time, reverse bool) error

Search this shard for queries between the provided time frames for message matched by the provided match function.

type ShardFile

type ShardFile struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ShardFile represents an individual stream of data in a shard.

func (*ShardFile) Close added in v0.2.0

func (s *ShardFile) Close() error

Close the backing files for a shard

func (*ShardFile) Search

func (s *ShardFile) Search(ctx context.Context, msgFunc logspray.MessageFunc, matcher ql.MatchFunc, from, to time.Time, reverse bool) error

Search searches the shard file for messages in the provided time range, matched by matcher, and passes them to msgFunc. If the reverse is true the file will be searched in reverse order

type ShardFileByStartTime added in v0.2.0

type ShardFileByStartTime []*ShardFile

func (ShardFileByStartTime) Len added in v0.2.0

func (so ShardFileByStartTime) Len() int

func (ShardFileByStartTime) Less added in v0.2.0

func (so ShardFileByStartTime) Less(i, j int) bool

func (ShardFileByStartTime) Swap added in v0.2.0

func (so ShardFileByStartTime) Swap(i, j int)

Jump to

Keyboard shortcuts

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