expr

package
v0.0.0-...-8d97d4a Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 47 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Annotate = map[string]parse.Func{

	"ancounts": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeSeriesSet,
		Tags:   tagFirst,
		F:      AnCounts,
	},
	"andurations": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeSeriesSet,
		Tags:   tagFirst,
		F:      AnDurations,
	},
	"antable": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeTable,
		F:      AnTable,
	},
}
View Source
var AzureMonitor = map[string]parse.Func{
	"az": {
		Args:          []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          azTags,
		F:             AzureQuery,
		PrefixEnabled: true,
	},
	"azmulti": {
		Args:          []models.FuncType{models.TypeString, models.TypeString, models.TypeAzureResourceList, models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          azMultiTags,
		F:             AzureMultiQuery,
		PrefixEnabled: true,
	},
	"azmd": {
		Args:          []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          tagFirst,
		F:             AzureMetricDefinitions,
		PrefixEnabled: true,
	},
	"azrt": {
		Args:          []models.FuncType{models.TypeString},
		Return:        models.TypeAzureResourceList,
		F:             AzureResourcesByType,
		PrefixEnabled: true,
	},
	"azrf": {
		Args:   []models.FuncType{models.TypeAzureResourceList, models.TypeString},
		Return: models.TypeAzureResourceList,
		F:      AzureFilterResources,
	},

	"aiapp": {
		Args:          []models.FuncType{},
		Return:        models.TypeAzureAIApps,
		F:             AzureAIListApps,
		PrefixEnabled: true,
	},
	"aiappf": {
		Args:          []models.FuncType{models.TypeAzureAIApps, models.TypeString},
		Return:        models.TypeAzureAIApps,
		F:             AzureAIFilterApps,
		PrefixEnabled: true,
	},
	"aimd": {
		Args:          []models.FuncType{models.TypeAzureAIApps},
		Return:        models.TypeInfo,
		F:             AzureAIMetricMD,
		PrefixEnabled: true,
	},
	"ai": {
		Args:          []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeAzureAIApps, models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          azAITags,
		F:             AzureAIQuery,
		PrefixEnabled: true,
	},
}

AzureMonitor is the collection of functions for the Azure monitor datasource

cloudwatch defines functions for use with amazon cloudwatch api

View Source
var DimensionParseError = errors.New("dimensions must be in format key:value")
View Source
var Elastic = map[string]parse.Func{

	"escount": {
		Args:          []models.FuncType{models.TypeESIndexer, models.TypeString, models.TypeESQuery, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          elasticTagQuery,
		F:             ESCount,
		PrefixEnabled: true,
	},
	"esstat": {
		Args:          []models.FuncType{models.TypeESIndexer, models.TypeString, models.TypeESQuery, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return:        models.TypeSeriesSet,
		Tags:          elasticTagQuery,
		F:             ESStat,
		PrefixEnabled: true,
	},

	"esindices": {
		Args:     []models.FuncType{models.TypeString, models.TypeString},
		VArgs:    true,
		VArgsPos: 1,
		Return:   models.TypeESIndexer,
		F:        ESIndicies,
	},
	"esdaily": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeESIndexer,
		F:      ESDaily,
	},
	"esmonthly": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeESIndexer,
		F:      ESMonthly,
	},
	"esls": {
		Args:   []models.FuncType{models.TypeString},
		Return: models.TypeESIndexer,
		F:      ESLS,
	},

	"esall": {
		Args:   []models.FuncType{},
		Return: models.TypeESQuery,
		F:      ESAll,
	},
	"esregexp": {
		Args:   []models.FuncType{models.TypeString, models.TypeString},
		Return: models.TypeESQuery,
		F:      ESRegexp,
	},
	"esquery": {
		Args:   []models.FuncType{models.TypeString, models.TypeString},
		Return: models.TypeESQuery,
		F:      ESQueryString,
	},
	"esexists": {
		Args:   []models.FuncType{models.TypeString},
		Return: models.TypeESQuery,
		F:      ESExists,
	},
	"esand": {
		Args:   []models.FuncType{models.TypeESQuery},
		VArgs:  true,
		Return: models.TypeESQuery,
		F:      ESAnd,
	},
	"esor": {
		Args:   []models.FuncType{models.TypeESQuery},
		VArgs:  true,
		Return: models.TypeESQuery,
		F:      ESOr,
	},
	"esnot": {
		Args:   []models.FuncType{models.TypeESQuery},
		Return: models.TypeESQuery,
		F:      ESNot,
	},
	"esgt": {
		Args:   []models.FuncType{models.TypeString, models.TypeScalar},
		Return: models.TypeESQuery,
		F:      ESGT,
	},
	"esgte": {
		Args:   []models.FuncType{models.TypeString, models.TypeScalar},
		Return: models.TypeESQuery,
		F:      ESGTE,
	},
	"eslt": {
		Args:   []models.FuncType{models.TypeString, models.TypeScalar},
		Return: models.TypeESQuery,
		F:      ESLT,
	},
	"eslte": {
		Args:   []models.FuncType{models.TypeString, models.TypeScalar},
		Return: models.TypeESQuery,
		F:      ESLTE,
	},
}

ElasticFuncs are specific functions that query an elasticsearch instance. They are only loaded when the elastic hosts are set in the config file

View Source
var EndParseError = errors.New("Could not parse the end value")
View Source
var ErrUnknownOp = fmt.Errorf("expr: unknown op type")
View Source
var Graphite = map[string]parse.Func{
	"graphiteBand": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   graphiteTagQuery,
		F:      GraphiteBand,
	},
	"graphite": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeSeriesSet,
		Tags:   graphiteTagQuery,
		F:      GraphiteQuery,
	},
}

Graphite defines functions for use with a Graphite backend.

Influx is a map of functions to query InfluxDB.

View Source
var PeriodParseError = errors.New("Could not parse the period value")
View Source
var Prom = map[string]parse.Func{
	"prom": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promGroupTags,
		F:             PromQuery,
		PrefixEnabled: true,
	},
	"promm": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promMGroupTags,
		F:             PromMQuery,
		PrefixEnabled: true,
	},
	"promrate": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promGroupTags,
		F:             PromRate,
		PrefixEnabled: true,
	},
	"promratem": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promMGroupTags,
		F:             PromMRate,
		PrefixEnabled: true,
	},
	"promras": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promAggRawTags,
		F:             PromRawAggSeriesQuery,
		PrefixEnabled: true,
	},
	"prommras": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeSeriesSet,
		Tags:          promMAggRawTags,
		F:             PromMRawAggSeriesQuery,
		PrefixEnabled: true,
	},
	"prommetrics": {
		Args:          []models.FuncType{},
		Return:        models.TypeInfo,
		F:             PromMetricList,
		PrefixEnabled: true,
	},
	"promtags": {
		Args: []models.FuncType{
			models.TypeString,
			models.TypeString,
			models.TypeString,
		},
		Return:        models.TypeInfo,
		F:             PromTagInfo,
		PrefixEnabled: true,
	},
}

Prom is a map of functions to query Prometheus.

View Source
var StartParseError = errors.New("Could not parse the start value")
View Source
var TSDB = map[string]parse.Func{
	"band": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      Band,
	},
	"bandQuery": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      BandQuery,
	},
	"shiftBand": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      ShiftBand,
	},
	"over": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      Over,
	},
	"overQuery": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeScalar},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      OverQuery,
	},
	"change": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeNumberSet,
		Tags:   tagQuery,
		F:      Change,
	},
	"count": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeScalar,
		F:      Count,
	},
	"q": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      Query,
	},
	"window": {
		Args:   []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeScalar, models.TypeString},
		Return: models.TypeSeriesSet,
		Tags:   tagQuery,
		F:      Window,
		Check:  windowCheck,
	},
}

TSDB defines functions for use with an OpenTSDB backend.

Functions

func ScopeES2

func ScopeES2(ts opentsdb.TagSet, q elastic.Query) elastic.Query

func ScopeES5

func ScopeES5(ts opentsdb.TagSet, q elastic.Query) elastic.Query

func ScopeES6

func ScopeES6(ts opentsdb.TagSet, q elastic.Query) elastic.Query

func ScopeES7

func ScopeES7(ts opentsdb.TagSet, q elastic.Query) elastic.Query

Types

type AlertStatusProvider

type AlertStatusProvider interface {
	GetUnknownAndUnevaluatedAlertKeys(alertName string) (unknown, unevaluated []models.AlertKey)
}

Alert Status Provider is used to provide information about alert results. This facilitates alerts referencing other alerts, even when they go unknown or unevaluated.

type AzureApplicationInsightsApp

type AzureApplicationInsightsApp struct {
	ApplicationName string
	AppId           string
	Tags            map[string]string
}

AzureApplicationInsightsApp in collection of properties for each Azure Application Insights Resource

func (AzureApplicationInsightsApp) Ask

func (app AzureApplicationInsightsApp) Ask(filter string) (bool, error)

Ask makes an AzureApplicationInsightsApp a github.com/kylebrandt/boolq Asker, which allows it to to take boolean expressions to create true/false conditions for filtering

type AzureApplicationInsightsApps

type AzureApplicationInsightsApps struct {
	Applications []AzureApplicationInsightsApp
	Prefix       string
}

AzureApplicationInsightsApps is a container for a list of AzureApplicationInsightsApp objects It is a bosun type since it passed to Azure Insights query functions

func (AzureApplicationInsightsApps) Type

func (AzureApplicationInsightsApps) Value

func (a AzureApplicationInsightsApps) Value() interface{}

type AzureMonitorClientCollection

type AzureMonitorClientCollection struct {
	MetricsClient           insights.MetricsClient
	MetricDefinitionsClient insights.MetricDefinitionsClient
	ResourcesClient         resources.Client
	AIComponentsClient      ainsightsmgmt.ComponentsClient
	AIMetricsClient         ainsights.MetricsClient
	Concurrency             int
	TenantId                string
}

AzureMonitorClientCollection is a collection of Azure SDK clients since the SDK provides different clients to access different sorts of resources

type AzureMonitorClients

type AzureMonitorClients map[string]AzureMonitorClientCollection

AzureMonitorClients is map of all the AzureMonitorClientCollections that have been configured. This is so multiple subscription/tenant/clients can be queries from the same Bosun instance using the prefix syntax

type AzureResource

type AzureResource struct {
	Name          string
	Type          string
	ResourceGroup string
	Tags          map[string]string
	ID            string
}

AzureResource is a container for Azure resource information that Bosun can interact with

func (AzureResource) Ask

func (ar AzureResource) Ask(filter string) (bool, error)

Ask makes an AzureResource a github.com/kylebrandt/boolq Asker, which allows it to take boolean expressions to create true/false conditions for filtering

type AzureResources

type AzureResources struct {
	Resources []AzureResource
	Prefix    string
}

AzureResources is a slice of AzureResource type AzureResources []AzureResource

func (AzureResources) Get

func (resources AzureResources) Get(rType, rsg, name string) (az AzureResource, found bool)

Get Returns an AzureResource from AzureResources based on the resource type, group, and name If no matching resource is found, an AzureResource object will be returned but found will be false.

func (AzureResources) Type

func (a AzureResources) Type() models.FuncType

func (AzureResources) Value

func (a AzureResources) Value() interface{}

type Backends

type Backends struct {
	TSDBContext       opentsdb.Context
	GraphiteContext   graphite.Context
	ElasticHosts      ElasticHosts
	InfluxConfig      client.HTTPConfig
	ElasticConfig     ElasticConfig
	AzureMonitor      AzureMonitorClients
	CloudWatchContext cloudwatch.Context
	PromConfig        PromClients
}

type BosunProviders

type BosunProviders struct {
	Squelched func(tags opentsdb.TagSet) bool
	Search    *search.Search
	History   AlertStatusProvider
	Cache     *cache.Cache
	Annotate  backend.Backend
}

type ESIndexer

type ESIndexer struct {
	TimeField string
	Generate  func(startDuration, endDuration *time.Time) []string
}

func (ESIndexer) MarshalJSON

func (e ESIndexer) MarshalJSON() ([]byte, error)

func (ESIndexer) Type

func (e ESIndexer) Type() models.FuncType

func (ESIndexer) Value

func (e ESIndexer) Value() interface{}

type ESQuery

type ESQuery struct {
	Query func(ver ESVersion) interface{}
}

func (ESQuery) MarshalJSON

func (e ESQuery) MarshalJSON() ([]byte, error)

func (ESQuery) Type

func (e ESQuery) Type() models.FuncType

func (ESQuery) Value

func (e ESQuery) Value() interface{}

type ESVersion

type ESVersion string
const (
	ESV2 ESVersion = "v2"
	ESV5 ESVersion = "v5"
	ESV6 ESVersion = "v6"
	ESV7 ESVersion = "v7"
)

type ElasticConfig

type ElasticConfig struct {
	Hosts             []string
	Version           ESVersion
	SimpleClient      bool
	ClientOptionFuncs interface{}
}

type ElasticHosts

type ElasticHosts struct {
	Hosts map[string]ElasticConfig
}

ElasticHosts is an array of Logstash hosts and exists as a type for something to attach methods to. The elasticsearch library will use the listed to hosts to discover all of the hosts in the config type ElasticHosts []string

func (ElasticHosts) InitClient

func (e ElasticHosts) InitClient(prefix string) error

InitClient sets up the elastic client. If the client has already been initialized it is a noop

func (ElasticHosts) InitClient2

func (e ElasticHosts) InitClient2(prefix string) error

InitClient sets up the elastic client. If the client has already been initialized it is a noop

func (ElasticHosts) InitClient5

func (e ElasticHosts) InitClient5(prefix string) error

InitClient sets up the elastic client. If the client has already been initialized it is a noop

func (ElasticHosts) InitClient6

func (e ElasticHosts) InitClient6(prefix string) error

InitClient sets up the elastic client. If the client has already been initialized it is a noop

func (ElasticHosts) InitClient7

func (e ElasticHosts) InitClient7(prefix string) error

InitClient sets up the elastic client. If the client has already been initialized it is a noop

func (ElasticHosts) Query2

Query takes a Logstash request, applies it a search service, and then queries elasticsearch.

func (ElasticHosts) Query5

Query takes a Logstash request, applies it a search service, and then queries elasticsearch.

func (ElasticHosts) Query6

Query takes a Logstash request, applies it a search service, and then queries elasticsearch.

func (ElasticHosts) Query7

Query takes a Logstash request, applies it a search service, and then queries elasticsearch.

type ElasticRequest2

type ElasticRequest2 struct {
	Indices []string
	HostKey string
	Start   *time.Time
	End     *time.Time
	Source  *elastic.SearchSource // This the object that we build queries in
}

ElasticRequest is a container for the information needed to query elasticsearch or a date histogram.

func ESBaseQuery2

func ESBaseQuery2(now time.Time, indexer ESIndexer, filter elastic.Query, sduration, eduration string, size int, prefix string) (*ElasticRequest2, error)

ESBaseQuery builds the base query that both ESCount and ESStat share

func (*ElasticRequest2) CacheKey

func (r *ElasticRequest2) CacheKey() (string, error)

CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache. It is a combination of the host key, indices queries and the json query content

type ElasticRequest5

type ElasticRequest5 struct {
	Indices []string
	HostKey string
	Start   *time.Time
	End     *time.Time
	Source  *elastic.SearchSource // This the object that we build queries in
}

ElasticRequest5 is a container for the information needed to query elasticsearch or a date histogram.

func ESBaseQuery5

func ESBaseQuery5(now time.Time, indexer ESIndexer, filter elastic.Query, sduration, eduration string, size int, prefix string) (*ElasticRequest5, error)

ESBaseQuery builds the base query that both ESCount and ESStat share

func (*ElasticRequest5) CacheKey

func (r *ElasticRequest5) CacheKey() (string, error)

CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache. It is a combination of the host key, indices queries and the json query content

type ElasticRequest6

type ElasticRequest6 struct {
	Indices []string
	HostKey string
	Start   *time.Time
	End     *time.Time
	Source  *elastic.SearchSource // This the object that we build queries in
}

ElasticRequest6 is a container for the information needed to query elasticsearch or a date histogram.

func ESBaseQuery6

func ESBaseQuery6(now time.Time, indexer ESIndexer, filter elastic.Query, sduration, eduration string, size int, prefix string) (*ElasticRequest6, error)

ESBaseQuery builds the base query that both ESCount and ESStat share

func (*ElasticRequest6) CacheKey

func (r *ElasticRequest6) CacheKey() (string, error)

CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache. It is a combination of the host key, indices queries and the json query content

type ElasticRequest7

type ElasticRequest7 struct {
	Indices []string
	HostKey string
	Start   *time.Time
	End     *time.Time
	Source  *elastic.SearchSource // This the object that we build queries in
}

ElasticRequest7 is a container for the information needed to query elasticsearch or a date histogram.

func ESBaseQuery7

func ESBaseQuery7(now time.Time, indexer ESIndexer, filter elastic.Query, sduration, eduration string, size int, prefix string) (*ElasticRequest7, error)

ESBaseQuery builds the base query that both ESCount and ESStat share

func (*ElasticRequest7) CacheKey

func (r *ElasticRequest7) CacheKey() (string, error)

CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache. It is a combination of the host key, indices queries and the json query content

type Expr

type Expr struct {
	*parse.Tree
}

func New

func New(expr string, funcs ...map[string]parse.Func) (*Expr, error)

New creates a new expression tree

func (*Expr) Execute

func (e *Expr) Execute(backends *Backends, providers *BosunProviders, T miniprofiler.Timer, now time.Time, autods int, unjoinedOk bool, origin string) (r *Results, queries []opentsdb.Request, err error)

Execute applies a parse expression to the specified OpenTSDB context, and returns one result per group. T may be nil to ignore timings.

func (*Expr) ExecuteState

func (e *Expr) ExecuteState(s *State) (r *Results, queries []opentsdb.Request, err error)

func (*Expr) MarshalJSON

func (e *Expr) MarshalJSON() ([]byte, error)

type Info

type Info []interface{}

func (Info) Type

func (i Info) Type() models.FuncType

func (Info) Value

func (i Info) Value() interface{}

type Number

type Number float64

func (Number) MarshalJSON

func (n Number) MarshalJSON() ([]byte, error)

func (Number) Type

func (n Number) Type() models.FuncType

func (Number) Value

func (n Number) Value() interface{}

type NumberExpr

type NumberExpr Expr

func (NumberExpr) Type

func (s NumberExpr) Type() models.FuncType

func (NumberExpr) Value

func (s NumberExpr) Value() interface{}

type PromClients

type PromClients map[string]promv1.API

PromClients is a collection of Prometheus API v1 client APIs (connections)

type Result

type Result struct {
	models.Computations
	Value
	Group opentsdb.TagSet
}

type ResultSlice

type ResultSlice []*Result

func (ResultSlice) DescByValue

func (r ResultSlice) DescByValue() ResultSlice

func (ResultSlice) Filter

func (r ResultSlice) Filter(filter opentsdb.TagSet) ResultSlice

Filter returns a slice with only the results that have a tagset that conforms to the given key/value pair restrictions

type ResultSliceByGroup

type ResultSliceByGroup ResultSlice

func (ResultSliceByGroup) Len

func (r ResultSliceByGroup) Len() int

func (ResultSliceByGroup) Less

func (r ResultSliceByGroup) Less(i, j int) bool

func (ResultSliceByGroup) Swap

func (r ResultSliceByGroup) Swap(i, j int)

type ResultSliceByValue

type ResultSliceByValue ResultSlice

func (ResultSliceByValue) Len

func (r ResultSliceByValue) Len() int

func (ResultSliceByValue) Less

func (r ResultSliceByValue) Less(i, j int) bool

func (ResultSliceByValue) Swap

func (r ResultSliceByValue) Swap(i, j int)

type Results

type Results struct {
	Results ResultSlice
	// If true, ungrouped joins from this set will be ignored.
	IgnoreUnjoined bool
	// If true, ungrouped joins from the other set will be ignored.
	IgnoreOtherUnjoined bool
	// If non nil, will set any NaN value to it.
	NaNValue *float64
}

func Abs

func Abs(e *State, set *Results) *Results

func AddTags

func AddTags(e *State, set *Results, s string) (*Results, error)

func Aggr

func Aggr(e *State, series *Results, groups string, aggregator string) (*Results, error)

Aggr combines multiple series matching the specified groups using an aggregator function. If group is empty, all given series are combined, regardless of existing groups. Available aggregator functions include: avg, min, max, sum, and pN, where N is a float between 0 and 1 inclusive, e.g. p.50 represents the 50th percentile. p0 and p1 are equal to min and max, respectively, but min and max are preferred for readability.

func AnCounts

func AnCounts(e *State, filter, startDuration, endDuration string) (r *Results, err error)

func AnDurations

func AnDurations(e *State, filter, startDuration, endDuration string) (r *Results, err error)

func AnTable

func AnTable(e *State, filter, fieldsCSV, startDuration, endDuration string) (r *Results, err error)

AnTable returns a table response (meant for Grafana) of matching annotations based on the requested fields

func Avg

func Avg(e *State, series *Results) (*Results, error)

func AzureAIFilterApps

func AzureAIFilterApps(prefix string, e *State, apps AzureApplicationInsightsApps, filter string) (r *Results, err error)

AzureAIFilterApps filters a list of applications based on the name of the app, or the Azure tags associated with the application resource

func AzureAIListApps

func AzureAIListApps(prefix string, e *State) (r *Results, err error)

AzureAIListApps get a list of all applications on the subscription and returns those apps in a AzureApplicationInsightsApps within the result

func AzureAIMetricMD

func AzureAIMetricMD(prefix string, e *State, apps AzureApplicationInsightsApps) (r *Results, err error)

AzureAIMetricMD returns metric metadata for the listed AzureApplicationInsightsApps. This is not meant as core expression function, but rather one for interactive inspection through the expression UI.

func AzureAIQuery

func AzureAIQuery(prefix string, e *State, metric, segmentCSV, filter string, apps AzureApplicationInsightsApps, agtype, interval, sdur, edur string) (r *Results, err error)

AzureAIQuery queries the Azure Application Insights API for metrics data and transforms the response into a series set

func AzureFilterResources

func AzureFilterResources(e *State, resources AzureResources, filter string) (r *Results, err error)

AzureFilterResources filters a list of resources based on the value of the name, resource group or tags associated with that resource

func AzureMetricDefinitions

func AzureMetricDefinitions(prefix string, e *State, namespace, metric, rsg, resource string) (r *Results, err error)

AzureMetricDefinitions fetches metric information for a specific resource and metric tuple TODO make this return and not fmt.Printf

func AzureMultiQuery

func AzureMultiQuery(prefix string, e *State, metric, tagKeysCSV string, resources AzureResources, agtype string, interval, sdur, edur string) (r *Results, err error)

AzureMultiQuery queries multiple Azure resources and returns them as a single result set It makes one HTTP request per resource and parallelizes the requests

func AzureQuery

func AzureQuery(prefix string, e *State, namespace, metric, tagKeysCSV, rsg, resName, agtype, interval, sdur, edur string) (r *Results, err error)

AzureQuery queries an Azure monitor metric for the given resource and returns a series set tagged by rsg (resource group), name (resource name), and any tag keys parsed from the tagKeysCSV argument

func AzureResourcesByType

func AzureResourcesByType(prefix string, e *State, tp string) (r *Results, err error)

AzureResourcesByType returns all resources of the specified type It fetches the complete list resources and then filters them relying on a Cache of that resource list

func Band

func Band(e *State, query, duration, period string, num float64) (r *Results, err error)

func BandQuery

func BandQuery(e *State, query, duration, period, eduration string, num float64) (r *Results, err error)

func CCount

func CCount(e *State, series *Results) (*Results, error)

func Change

func Change(e *State, query, sduration, eduration string) (r *Results, err error)

func CloudWatchQuery

func CloudWatchQuery(prefix string, e *State, region, namespace, metric, period, statistic, dimensions, sduration, eduration string) (*Results, error)

func Count

func Count(e *State, query, sduration, eduration string) (r *Results, err error)

func Crop

func Crop(e *State, sSet *Results, startSet *Results, endSet *Results) (*Results, error)

func Des

func Des(e *State, series *Results, alpha float64, beta float64) *Results

func Dev

func Dev(e *State, series *Results) (*Results, error)

func Diff

func Diff(e *State, series *Results) (r *Results, err error)

func DropBool

func DropBool(e *State, target *Results, filter *Results) (*Results, error)

func DropG

func DropG(e *State, series *Results, threshold *Results) (*Results, error)

func DropGe

func DropGe(e *State, series *Results, threshold *Results) (*Results, error)

func DropL

func DropL(e *State, series *Results, threshold *Results) (*Results, error)

func DropLe

func DropLe(e *State, series *Results, threshold *Results) (*Results, error)

func DropNA

func DropNA(e *State, series *Results) (*Results, error)

func DropValues

func DropValues(e *State, series *Results, threshold *Results, dropFunction func(float64, float64) bool) (*Results, error)

func Duration

func Duration(e *State, d string) (*Results, error)

func ESAll

func ESAll(e *State) (*Results, error)

func ESAnd

func ESAnd(e *State, esqueries ...ESQuery) (*Results, error)

func ESCount

func ESCount(prefix string, e *State, indexer ESIndexer, keystring string, filter ESQuery, interval, sduration, eduration string) (r *Results, err error)

func ESDaily

func ESDaily(e *State, timeField, indexRoot, layout string) (*Results, error)

func ESDateHistogram2

func ESDateHistogram2(prefix string, e *State, indexer ESIndexer, keystring string, filter elastic.Query, interval, sduration, eduration, stat_field, rstat string, size int) (r *Results, err error)

func ESDateHistogram5

func ESDateHistogram5(prefix string, e *State, indexer ESIndexer, keystring string, filter elastic.Query, interval, sduration, eduration, stat_field, rstat string, size int) (r *Results, err error)

func ESDateHistogram6

func ESDateHistogram6(prefix string, e *State, indexer ESIndexer, keystring string, filter elastic.Query, interval, sduration, eduration, stat_field, rstat string, size int) (r *Results, err error)

func ESDateHistogram7

func ESDateHistogram7(prefix string, e *State, indexer ESIndexer, keystring string, filter elastic.Query, interval, sduration, eduration, stat_field, rstat string, size int) (r *Results, err error)

func ESExists

func ESExists(e *State, field string) (*Results, error)

func ESGT

func ESGT(e *State, key string, gt float64) (*Results, error)

func ESGTE

func ESGTE(e *State, key string, gte float64) (*Results, error)

func ESIndicies

func ESIndicies(e *State, timeField string, literalIndices ...string) *Results

func ESLS

func ESLS(e *State, indexRoot string) (*Results, error)

func ESLT

func ESLT(e *State, key string, lt float64) (*Results, error)

func ESLTE

func ESLTE(e *State, key string, lte float64) (*Results, error)

func ESMonthly

func ESMonthly(e *State, timeField, indexRoot, layout string) (*Results, error)

func ESNot

func ESNot(e *State, query ESQuery) (*Results, error)

func ESOr

func ESOr(e *State, esqueries ...ESQuery) (*Results, error)

func ESQueryString

func ESQueryString(e *State, key string, query string) (*Results, error)

func ESRegexp

func ESRegexp(e *State, key string, regex string) (*Results, error)

func ESStat

func ESStat(prefix string, e *State, indexer ESIndexer, keystring string, filter ESQuery, field, rstat, interval, sduration, eduration string) (r *Results, err error)

ESStat returns a bucketed statistical reduction for the specified field.

func Epoch

func Epoch(e *State) (*Results, error)

func Filter

func Filter(e *State, set *Results, numberSet *Results) (*Results, error)

func First

func First(e *State, series *Results) (*Results, error)

func Forecast_lr

func Forecast_lr(e *State, series *Results, y *Results) (r *Results, err error)

func GraphiteBand

func GraphiteBand(e *State, query, duration, period, format string, num float64) (r *Results, err error)

func GraphiteQuery

func GraphiteQuery(e *State, query string, sduration, eduration, format string) (r *Results, err error)

func InfluxQuery

func InfluxQuery(e *State, db, query, startDuration, endDuration, groupByInterval string) (*Results, error)

func IsNaN

func IsNaN(e *State, nSet *Results) (*Results, error)

func Last

func Last(e *State, series *Results) (*Results, error)

func LeftJoin

func LeftJoin(e *State, keysCSV, columnsCSV string, rowData ...*Results) (*Results, error)

func Length

func Length(e *State, series *Results) (*Results, error)

func Limit

func Limit(e *State, set *Results, v float64) (*Results, error)

func Line_lr

func Line_lr(e *State, series *Results, d string) (*Results, error)

func Map

func Map(e *State, series *Results, expr *Results) (*Results, error)

func Max

func Max(e *State, series *Results) (r *Results, err error)

func Median

func Median(e *State, series *Results) (r *Results, err error)

func Merge

func Merge(e *State, series ...*Results) (*Results, error)

func Min

func Min(e *State, series *Results) (r *Results, err error)

func Month

func Month(e *State, offset float64, startEnd string) (*Results, error)

func NV

func NV(e *State, series *Results, v float64) (results *Results, err error)

func Over

func Over(e *State, query, duration, period string, num float64) (r *Results, err error)

func OverQuery

func OverQuery(e *State, query, duration, period, eduration string, num float64) (r *Results, err error)

func Percentile

func Percentile(e *State, series *Results, p *Results) (r *Results, err error)

func PromMQuery

func PromMQuery(prefix string, e *State, metric, groupBy, filter, agType, stepDuration, sdur, edur string) (r *Results, err error)

PromMQuery is a wrapper from promMQuery in the way that PromQuery is a wrapper from promQuery.

func PromMRate

func PromMRate(prefix string, e *State, metric, groupBy, filter, agType, rateDuration, stepDuration, sdur, edur string) (r *Results, err error)

PromMRate is a wrapper from promMQuery in the way that PromRate is a wrapper from promQuery. It has a stepDuration argument for rate calculation.

func PromMRawAggSeriesQuery

func PromMRawAggSeriesQuery(prefix string, e *State, query, stepDuration, sdur, edur string) (*Results, error)

PromMRawAggSeriesQuery is wrapper for promRawAggSeriesQuery setting the multi argument to true.

func PromMetricList

func PromMetricList(prefix string, e *State) (r *Results, err error)

PromMetricList returns a list of available metrics for the prometheus backend by using querying the Prometheus Label Values API for "__name__"

func PromQuery

func PromQuery(prefix string, e *State, metric, groupBy, filter, agType, stepDuration, sdur, edur string) (r *Results, err error)

PromQuery is a wrapper for promQuery so there is a function signature that doesn't require the rate argument in the expr language. It also sets promQuery's addPrefixTag argument to false since this only queries one backend.

func PromRate

func PromRate(prefix string, e *State, metric, groupBy, filter, agType, rateDuration, stepDuration, sdur, edur string) (r *Results, err error)

PromRate is a wrapper for promQuery like PromQuery except that it has a rateDuration argument for the step of the rate calculation. This enables rate calculation for counters.

func PromRawAggSeriesQuery

func PromRawAggSeriesQuery(prefix string, e *State, query, stepDuration, sdur, edur string) (*Results, error)

PromRawAggSeriesQuery is wrapper for promRawAggSeriesQuery setting the multi argument to false.

func PromTagInfo

func PromTagInfo(prefix string, e *State, metric, sdur, edur string) (r *Results, err error)

PromTagInfo does a range query for the given metric and returns info about the tags and labels for the metric based on the data from the queried timeframe

func Query

func Query(e *State, query, sduration, eduration string) (r *Results, err error)

func Remove

func Remove(e *State, set *Results, tagKey string) (*Results, error)

func Rename

func Rename(e *State, set *Results, s string) (*Results, error)

func SeriesFunc

func SeriesFunc(e *State, tags string, pairs ...float64) (*Results, error)

func Shift

func Shift(e *State, series *Results, d string) (*Results, error)

func ShiftBand

func ShiftBand(e *State, query, duration, period string, num float64) (r *Results, err error)

func Since

func Since(e *State, series *Results) (*Results, error)

func Sort

func Sort(e *State, series *Results, order string) (*Results, error)

func Streak

func Streak(e *State, series *Results) (*Results, error)

func Sum

func Sum(e *State, series *Results) (*Results, error)

func Tail

func Tail(e *State, series *Results, number *Results) (*Results, error)

func TimeDelta

func TimeDelta(e *State, series *Results) (*Results, error)

func ToDuration

func ToDuration(e *State, sec float64) (*Results, error)

func Transpose

func Transpose(e *State, d *Results, gp string) (*Results, error)

func Ungroup

func Ungroup(e *State, d *Results) (*Results, error)

func V

func V(e *State) (*Results, error)

func Window

func Window(e *State, query, duration, period string, num float64, rfunc string) (*Results, error)

func (*Results) Equal

func (a *Results) Equal(b *Results) (bool, error)

Equal inspects if two results have the same content error will return why they are not equal if they are not equal

func (*Results) NaN

func (r *Results) NaN() Number

type Scalar

type Scalar float64

func (Scalar) MarshalJSON

func (s Scalar) MarshalJSON() ([]byte, error)

func (Scalar) Type

func (s Scalar) Type() models.FuncType

func (Scalar) Value

func (s Scalar) Value() interface{}

type Series

type Series map[time.Time]float64

Series is the standard form within bosun to represent timeseries data.

func (Series) Equal

func (a Series) Equal(b Series) bool

func (Series) MarshalJSON

func (s Series) MarshalJSON() ([]byte, error)

func (Series) Type

func (s Series) Type() models.FuncType

func (Series) Value

func (s Series) Value() interface{}

type SortablePoint

type SortablePoint struct {
	T time.Time
	V float64
}

type SortableSeries

type SortableSeries []SortablePoint

SortableSeries is an alternative datastructure for timeseries data, which stores points in a time-ordered fashion instead of a map. see discussion at https://github.com/bosun-monitor/bosun/pull/699

func NewSortedSeries

func NewSortedSeries(dps Series) SortableSeries

func (SortableSeries) Len

func (s SortableSeries) Len() int

func (SortableSeries) Less

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

func (SortableSeries) Swap

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

type State

type State struct {
	*Expr

	// Origin allows the source of the expression to be identified for logging and debugging
	Origin string

	Timer miniprofiler.Timer

	*Backends

	// Bosun Internal
	*BosunProviders
	// contains filtered or unexported fields
}

func (*State) AddComputation

func (e *State) AddComputation(r *Result, text string, value interface{})

type String

type String string

func (String) Type

func (s String) Type() models.FuncType

func (String) Value

func (s String) Value() interface{}

type Table

type Table struct {
	Columns []string
	Rows    [][]interface{}
}

func (Table) Type

func (t Table) Type() models.FuncType

func (Table) Value

func (t Table) Value() interface{}

type Union

type Union struct {
	models.Computations
	A, B  Value
	Group opentsdb.TagSet
}

func (*Union) ExtendComputations

func (u *Union) ExtendComputations(o *Result)

type Value

type Value interface {
	Type() models.FuncType
	Value() interface{}
}

Directories

Path Synopsis
Package parse builds parse trees for expressions as defined by expr.
Package parse builds parse trees for expressions as defined by expr.

Jump to

Keyboard shortcuts

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