expr

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LineModeSlope     LineMode = 1
	LineModeStaircase          = 2
	LineModeConnected          = 4
)
View Source
const (
	AreaModeNone    AreaMode = 1
	AreaModeFirst            = 2
	AreaModeAll              = 4
	AreaModeStacked          = 8
)
View Source
const (
	PieModeMaximum PieMode = 1
	PieModeMinimum         = 2
	PieModeAverage         = 4
)

Variables

View Source
var (
	// ErrMissingExpr is a parse error returned when an expression is missing.
	ErrMissingExpr = errors.New("missing expression")
	// ErrMissingComma is a parse error returned when an expression is missing a comma.
	ErrMissingComma = errors.New("missing comma")
	// ErrMissingQuote is a parse error returned when an expression is missing a quote.
	ErrMissingQuote = errors.New("missing quote")
	// ErrUnexpectedCharacter is a parse error returned when an expression contains an unexpected character.
	ErrUnexpectedCharacter = errors.New("unexpected character")
)
View Source
var (
	// ErrBadType is an eval error returned when a argument has wrong type.
	ErrBadType = errors.New("bad type")
	// ErrMissingArgument is an eval error returned when a argument is missing.
	ErrMissingArgument = errors.New("missing argument")
	// ErrMissingTimeseries is an eval error returned when a time series argument is missing.
	ErrMissingTimeseries = errors.New("missing time series argument")
	// ErrSeriesDoesNotExist is an eval error returned when a requested time series argument does not exist.
	ErrSeriesDoesNotExist = errors.New("no timeseries with that name")
)
View Source
var (
	// ErrWildcardNotAllowed is an eval error returned when a wildcard/glob argument is found where a single series is required.
	ErrWildcardNotAllowed = errors.New("found wildcard where series expected")
	// ErrTooManyArguments is an eval error returned when too many arguments are provided.
	ErrTooManyArguments = errors.New("too many arguments")
)
View Source
var DefaultColorList = []string{"blue", "green", "red", "purple", "brown", "yellow", "aqua", "grey", "magenta", "pink", "gold", "rose"}
View Source
var DefaultParams = PictureParams{
	Width:      330,
	Height:     250,
	Margin:     10,
	LogBase:    0,
	FgColor:    "white",
	BgColor:    "black",
	MajorLine:  "rose",
	MinorLine:  "grey",
	FontName:   "Sans",
	FontSize:   10,
	FontBold:   FontWeightNormal,
	FontItalic: FontSlantNormal,

	GraphOnly:  false,
	HideLegend: false,
	HideGrid:   false,
	HideAxes:   false,
	HideYAxis:  false,
	HideXAxis:  false,
	YAxisSide:  YAxisSideLeft,

	Title:       "",
	Vtitle:      "",
	VtitleRight: "",

	Tz: time.Local,

	ConnectedLimit: math.MaxInt32,
	LineMode:       LineModeSlope,
	AreaMode:       AreaModeNone,
	AreaAlpha:      math.NaN(),
	PieMode:        PieModeAverage,
	LineWidth:      1.2,
	ColorList:      DefaultColorList,

	YMin:    math.NaN(),
	YMax:    math.NaN(),
	YStep:   math.NaN(),
	XMin:    math.NaN(),
	XMax:    math.NaN(),
	XStep:   math.NaN(),
	XFormat: "",
	MinorY:  1,

	UniqueLegend:   false,
	DrawNullAsZero: false,
	DrawAsInfinite: false,

	YMinLeft:    math.NaN(),
	YMinRight:   math.NaN(),
	YMaxLeft:    math.NaN(),
	YMaxRight:   math.NaN(),
	YStepL:      math.NaN(),
	YStepR:      math.NaN(),
	YLimitLeft:  math.NaN(),
	YLimitRight: math.NaN(),

	YUnitSystem: "si",
	YDivisors:   []float64{4, 5, 6},

	RightWidth:  1.2,
	RightDashed: false,
	RightColor:  "",
	LeftWidth:   1.2,
	LeftDashed:  false,
	LeftColor:   "",

	MajorGridLineColor: "white",
	MinorGridLineColor: "grey",
}
View Source
var RangeTables []*unicode.RangeTable

RangeTables is an array of *unicode.RangeTable

Functions

func AlphabeticallyByPart

func AlphabeticallyByPart(metrics []*MetricData, part int) sort.Interface

AlphabeticallyByPart returns a byPartAlphabetical that will sort 'metrics' alphabetically by 'part'.

func ByPart

func ByPart(metrics []*MetricData, part int) byPartBase

ByPart returns a byPartBase suitable for sorting 'metrics' by 'part'.

func ConsolidateJSON

func ConsolidateJSON(maxDataPoints int, results []*MetricData)

func IntervalString

func IntervalString(s string, defaultSign int) (int32, error)

IntervalString converts a sign and string into a number of seconds

func MarshalCSV

func MarshalCSV(results []*MetricData) []byte

func MarshalJSON

func MarshalJSON(results []*MetricData) []byte

func MarshalPNG

func MarshalPNG(params PictureParams, results []*MetricData) []byte

func MarshalPNGRequest added in v0.9.0

func MarshalPNGRequest(r *http.Request, results []*MetricData) []byte

func MarshalPickle

func MarshalPickle(results []*MetricData) []byte

func MarshalProtobuf

func MarshalProtobuf(results []*MetricData) ([]byte, error)

func MarshalRaw

func MarshalRaw(results []*MetricData) []byte

func MarshalSVG

func MarshalSVG(params PictureParams, results []*MetricData) []byte

func MarshalSVGRequest added in v0.9.0

func MarshalSVGRequest(r *http.Request, results []*MetricData) []byte

func ParseExpr

func ParseExpr(e string) (*expr, string, error)

func RewriteExpr added in v0.9.0

func RewriteExpr(e *expr, from, until int32, values map[MetricRequest][]*MetricData) (bool, []string, error)

RewriteExpr expands targets that use applyByNode into a new list of targets. eg: applyByNode(foo*, 1, "%") -> (true, ["foo1", "foo2"], nil) sumSeries(foo) -> (false, nil, nil) Assumes that applyByNode only appears as the outermost function.

func SortMetrics

func SortMetrics(metrics []*MetricData, mfetch MetricRequest)

func TruthyBool

func TruthyBool(s string) bool

Types

type AreaMode added in v0.9.0

type AreaMode int

type ByName

type ByName []*MetricData

ByName sorts metrics by name

func (ByName) Len

func (s ByName) Len() int

func (ByName) Less

func (s ByName) Less(i, j int) bool

func (ByName) Swap

func (s ByName) Swap(i, j int)

type ByNameNatural

type ByNameNatural []*MetricData

ByNameNatural sorts metric naturally by name

func (ByNameNatural) Len

func (s ByNameNatural) Len() int

func (ByNameNatural) Less

func (s ByNameNatural) Less(i, j int) bool

func (ByNameNatural) Swap

func (s ByNameNatural) Swap(i, j int)

type FontSlant added in v0.9.0

type FontSlant int
const (
	FontSlantNormal FontSlant = iota
	FontSlantItalic
	FontSlantOblique
)

type FontWeight added in v0.9.0

type FontWeight int
const (
	FontWeightNormal FontWeight = iota
	FontWeightBold
)

type LineMode added in v0.9.0

type LineMode int

type MetricData

type MetricData struct {
	pb.FetchResponse
	// contains filtered or unexported fields
}

func EvalExpr

func EvalExpr(e *expr, from, until int32, values map[MetricRequest][]*MetricData) ([]*MetricData, error)

func (*MetricData) AggregateValues

func (r *MetricData) AggregateValues()

func (*MetricData) AggregatedAbsent

func (r *MetricData) AggregatedAbsent() []bool

func (*MetricData) AggregatedTimeStep

func (r *MetricData) AggregatedTimeStep() int32

func (*MetricData) AggregatedValues

func (r *MetricData) AggregatedValues() []float64

type MetricRequest

type MetricRequest struct {
	Metric string
	From   int32
	Until  int32
}

type PictureParams added in v0.9.0

type PictureParams struct {
	Width      float64
	Height     float64
	Margin     int
	LogBase    float64
	FgColor    string
	BgColor    string
	MajorLine  string
	MinorLine  string
	FontName   string
	FontSize   float64
	FontBold   FontWeight
	FontItalic FontSlant

	GraphOnly  bool
	HideLegend bool
	HideGrid   bool
	HideAxes   bool
	HideYAxis  bool
	HideXAxis  bool
	YAxisSide  YAxisSide

	Title       string
	Vtitle      string
	VtitleRight string

	Tz *time.Location

	ConnectedLimit int
	LineMode       LineMode
	AreaMode       AreaMode
	AreaAlpha      float64
	PieMode        PieMode
	LineWidth      float64
	ColorList      []string

	YMin    float64
	YMax    float64
	XMin    float64
	XMax    float64
	YStep   float64
	XStep   float64
	MinorY  int
	XFormat string

	YMaxLeft    float64
	YLimitLeft  float64
	YMaxRight   float64
	YLimitRight float64
	YMinLeft    float64
	YMinRight   float64
	YStepL      float64
	YStepR      float64

	UniqueLegend   bool
	DrawNullAsZero bool
	DrawAsInfinite bool

	YUnitSystem string
	YDivisors   []float64

	RightWidth  float64
	RightDashed bool
	RightColor  string
	LeftWidth   float64
	LeftDashed  bool
	LeftColor   string

	MinorGridLineColor string
	MajorGridLineColor string
}

func GetPictureParams added in v0.9.0

func GetPictureParams(r *http.Request, metricData []*MetricData) PictureParams

type PieMode added in v0.9.0

type PieMode int

type YAxisSide added in v0.9.0

type YAxisSide int
const (
	YAxisSideRight YAxisSide = 1
	YAxisSideLeft            = 2
)

Jump to

Keyboard shortcuts

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