tgres: github.com/tgres/tgres/dsl Index | Files

package dsl

import "github.com/tgres/tgres/dsl"

Package dsl is the Domain Specific Language for the series query. Presently it mostly mimics the Graphite API functions. The parser used for the language is Go standard lib parser.ParseExpr(), which basically means the syntax is Go, and so the user of this package might need to ensure to wrap series names in quotes, etc.

For example, consider

scale(foo.bar.baz, 2)

is a valid Go expression. foo.bar.baz is called a selector expression. However,

scale(foo.1bar.baz, 2)

is not valid because an identifier cannot begin with a digit. In any case,

scale("foo.1bar.b*", 2)

is always valid, and is the preferred method.

Tgres DSL also supports function chaining, e.g.:

group("foo.*").scale(2)

Internally this is done by taking the return value of the preceeding function and inserting it as the first argument to the current one, thus the above expression is equivalent to:

scale(group("foo.*", 2))

Index

Package Files

aliasseries.go ds_lru.go dsl.go fs_find_cache.go funcs.go named_ds.go named_ds_map.go seriesmap.go

func NewNamedDSFetcher Uses

func NewNamedDSFetcher(db dsFetcherSearcher, dsc watcher, lruCap int) *namedDsFetcher

Returns a new instance of a NamedDSFetcher. The current implementation will re-fetch all series names any time a series cannot be found. TODO: Make this better.

func NewNamedDSFetcherMap Uses

func NewNamedDSFetcherMap(dss map[string]rrd.DataSourcer) *namedDsFetcher

Creates a NamedDsFetcher from a map of DataSourcers. This is useful to bootstrap a DSL Context without any database.

type AliasSeries Uses

type AliasSeries interface {
    series.Series
    // With argument sets the alias. Returns the alias.
    Alias(s ...string) string
}

A Series which supports Alias()

type DataPoint Uses

type DataPoint struct {
    serde.Ident
    T   time.Time
    V   float64
}

type FsFindNode Uses

type FsFindNode struct {
    Name       string
    Leaf       bool
    Expandable bool
    // contains filtered or unexported fields
}

type NamedDSFetcher Uses

type NamedDSFetcher interface {
    // contains filtered or unexported methods
}

A NamedDSFetcher is a serde.Fetcher which also implements a method for finding DS's by its dotted name using filepath.Match-like syntax.

type NamedDsFetcherStats Uses

type NamedDsFetcherStats struct {
    LruEvictions int
    LruSize      int
    LruHits      int
    LruMisses    int
}

type SeriesMap Uses

type SeriesMap map[string]AliasSeries

SeriesMap is a map and should not be confused with series.SeriesSlice. The key distinction is that you cannot "see" beyond a SeriesSlice, it encapsulates and hides all Series within it. E.g. when we compute avg(a, b), we end up with a new series and no longer have access to a or b. This is done by way of SeriesSlice.

The test is whether a "new" series is created. E.g. scale() is given a bunch of series, and returns a bunch of series, so it should use SeriesMap. avg() takes a bunch of series and returns only one series, so it's a SeriesSlice.

SeriesSlice

- based on []Series
- satisfies Series interface
- aligns Series' within it to match on group by
- series in it are not associated with a name (key)
- it's a "mix of series" that can be treated as a series
- supports duplicates

SeriesMap

- alias for map[string]Series
- does NOT implement Series, it's a container of series, but not a series
- is how we give Series names - the key is the name
- does not support duplicates - same series would need different names

func ParseDsl Uses

func ParseDsl(db ctxDSFetcher, src string, from, to time.Time, maxPoints int64) (SeriesMap, error)

Parse a DSL expression given by src and other params.

func (SeriesMap) SortedKeys Uses

func (sm SeriesMap) SortedKeys() []string

Package dsl imports 18 packages (graph) and is imported by 4 packages. Updated 2017-07-08. Refresh now. Tools for package owners.