Documentation ¶
Index ¶
- Variables
- func ProcessLSKeys(keystring, filter string, filtered *elastic.FilteredQuery) ([]lsKeyMatch, error)
- func ScopeES(ts opentsdb.TagSet, q elastic.Query) elastic.Query
- type AlertStatusProvider
- type Backends
- type BosunProviders
- type ESIndexer
- type ESQuery
- type ElasticHosts
- type ElasticRequest
- type Expr
- func (e *Expr) Execute(backends *Backends, providers *BosunProviders, T miniprofiler.Timer, ...) (r *Results, queries []opentsdb.Request, err error)
- func (e *Expr) ExecuteState(s *State, T miniprofiler.Timer) (r *Results, queries []opentsdb.Request, err error)
- func (e *Expr) MarshalJSON() ([]byte, error)
- type LogstashElasticHosts
- type LogstashRequest
- type Number
- type NumberExpr
- type Result
- type ResultSlice
- type ResultSliceByGroup
- type ResultSliceByValue
- type Results
- func Abs(e *State, T miniprofiler.Timer, series *Results) *Results
- func AddTags(e *State, T miniprofiler.Timer, series *Results, s string) (*Results, error)
- func Avg(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Band(e *State, T miniprofiler.Timer, query, duration, period string, num float64) (r *Results, err error)
- func CCount(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Change(e *State, T miniprofiler.Timer, query, sduration, eduration string) (r *Results, err error)
- func Count(e *State, T miniprofiler.Timer, query, sduration, eduration string) (r *Results, err error)
- func Crop(e *State, T miniprofiler.Timer, sSet *Results, startSet *Results, ...) (*Results, error)
- func Des(e *State, T miniprofiler.Timer, series *Results, alpha float64, beta float64) *Results
- func Dev(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Diff(e *State, T miniprofiler.Timer, series *Results) (r *Results, err error)
- func DropBool(e *State, T miniprofiler.Timer, target *Results, filter *Results) (*Results, error)
- func DropG(e *State, T miniprofiler.Timer, series *Results, threshold *Results) (*Results, error)
- func DropGe(e *State, T miniprofiler.Timer, series *Results, threshold *Results) (*Results, error)
- func DropL(e *State, T miniprofiler.Timer, series *Results, threshold *Results) (*Results, error)
- func DropLe(e *State, T miniprofiler.Timer, series *Results, threshold *Results) (*Results, error)
- func DropNA(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func DropValues(e *State, T miniprofiler.Timer, series *Results, threshold *Results, ...) (*Results, error)
- func Duration(e *State, T miniprofiler.Timer, d string) (*Results, error)
- func ESAll(e *State, T miniprofiler.Timer) (*Results, error)
- func ESAnd(e *State, T miniprofiler.Timer, esqueries ...ESQuery) (*Results, error)
- func ESCount(e *State, T miniprofiler.Timer, indexer ESIndexer, keystring string, ...) (r *Results, err error)
- func ESDaily(e *State, T miniprofiler.Timer, timeField, indexRoot, layout string) (*Results, error)
- func ESDateHistogram(e *State, T miniprofiler.Timer, indexer ESIndexer, keystring string, ...) (r *Results, err error)
- func ESExists(e *State, T miniprofiler.Timer, field string) (*Results, error)
- func ESGT(e *State, T miniprofiler.Timer, key string, gt float64) (*Results, error)
- func ESGTE(e *State, T miniprofiler.Timer, key string, gte float64) (*Results, error)
- func ESIndicies(e *State, T miniprofiler.Timer, timeField string, literalIndices ...string) (*Results, error)
- func ESLS(e *State, T miniprofiler.Timer, indexRoot string) (*Results, error)
- func ESLT(e *State, T miniprofiler.Timer, key string, lt float64) (*Results, error)
- func ESLTE(e *State, T miniprofiler.Timer, key string, lte float64) (*Results, error)
- func ESNot(e *State, T miniprofiler.Timer, query ESQuery) (*Results, error)
- func ESOr(e *State, T miniprofiler.Timer, esqueries ...ESQuery) (*Results, error)
- func ESQueryString(e *State, T miniprofiler.Timer, key string, query string) (*Results, error)
- func ESRegexp(e *State, T miniprofiler.Timer, key string, regex string) (*Results, error)
- func ESStat(e *State, T miniprofiler.Timer, indexer ESIndexer, keystring string, ...) (r *Results, err error)
- func Epoch(e *State, T miniprofiler.Timer) (*Results, error)
- func Filter(e *State, T miniprofiler.Timer, series *Results, number *Results) (*Results, error)
- func First(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Forecast_lr(e *State, T miniprofiler.Timer, series *Results, y *Results) (r *Results, err error)
- func GraphiteBand(e *State, T miniprofiler.Timer, query, duration, period, format string, ...) (r *Results, err error)
- func GraphiteQuery(e *State, T miniprofiler.Timer, query string, ...) (r *Results, err error)
- func InfluxQuery(e *State, T miniprofiler.Timer, ...) (*Results, error)
- func LSCount(e *State, T miniprofiler.Timer, ...) (r *Results, err error)
- func LSDateHistogram(e *State, T miniprofiler.Timer, ...) (r *Results, err error)
- func LSStat(e *State, T miniprofiler.Timer, ...) (r *Results, err error)
- func Last(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func LeftJoin(e *State, T miniprofiler.Timer, keysCSV, columnsCSV string, ...) (*Results, error)
- func Length(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Limit(e *State, T miniprofiler.Timer, series *Results, v float64) (*Results, error)
- func Line_lr(e *State, T miniprofiler.Timer, series *Results, d string) (*Results, error)
- func Map(e *State, T miniprofiler.Timer, series *Results, expr *Results) (*Results, error)
- func Max(e *State, T miniprofiler.Timer, series *Results) (r *Results, err error)
- func Median(e *State, T miniprofiler.Timer, series *Results) (r *Results, err error)
- func Merge(e *State, T miniprofiler.Timer, series ...*Results) (*Results, error)
- func Min(e *State, T miniprofiler.Timer, series *Results) (r *Results, err error)
- func Month(e *State, T miniprofiler.Timer, offset float64, startEnd string) (*Results, error)
- func NV(e *State, T miniprofiler.Timer, series *Results, v float64) (results *Results, err error)
- func Over(e *State, T miniprofiler.Timer, query, duration, period string, num float64) (r *Results, err error)
- func Percentile(e *State, T miniprofiler.Timer, series *Results, p *Results) (r *Results, err error)
- func Query(e *State, T miniprofiler.Timer, query, sduration, eduration string) (r *Results, err error)
- func Rename(e *State, T miniprofiler.Timer, series *Results, s string) (*Results, error)
- func SeriesFunc(e *State, T miniprofiler.Timer, tags string, pairs ...float64) (*Results, error)
- func Shift(e *State, T miniprofiler.Timer, series *Results, d string) (*Results, error)
- func ShiftBand(e *State, T miniprofiler.Timer, query, duration, period string, num float64) (r *Results, err error)
- func Since(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Sort(e *State, T miniprofiler.Timer, series *Results, order string) (*Results, error)
- func Streak(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Sum(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Tail(e *State, T miniprofiler.Timer, series *Results, number *Results) (*Results, error)
- func TimeDelta(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func ToDuration(e *State, T miniprofiler.Timer, sec float64) (*Results, error)
- func Transpose(e *State, T miniprofiler.Timer, d *Results, gp string) (*Results, error)
- func Ungroup(e *State, T miniprofiler.Timer, d *Results) (*Results, error)
- func V(e *State, T miniprofiler.Timer) (*Results, error)
- func Window(e *State, T miniprofiler.Timer, query, duration, period string, num float64, ...) (*Results, error)
- type Scalar
- type Series
- type SortablePoint
- type SortableSeries
- type State
- type String
- type Table
- type Union
- type Value
Constants ¶
This section is empty.
Variables ¶
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, }, "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, }, "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}, VArgs: true, VArgsPos: 1, Return: models.TypeESIndexer, F: ESDaily, }, "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
var ErrUnknownOp = fmt.Errorf("expr: unknown op type")
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.
var Influx = map[string]parse.Func{ "influx": { Args: []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString}, Return: models.TypeSeriesSet, Tags: influxTag, F: InfluxQuery, }, }
Influx is a map of functions to query InfluxDB.
var LogstashElastic = map[string]parse.Func{ "lscount": { Args: []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString}, Return: models.TypeSeriesSet, Tags: logstashTagQuery, F: LSCount, }, "lsstat": { Args: []models.FuncType{models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString, models.TypeString}, Return: models.TypeSeriesSet, Tags: logstashTagQuery, F: LSStat, }, }
The following are specific functions that query an elastic instance populated by logstash. They are only loaded when the elastic hosts are set in the config file
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, }, "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, }, "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 ProcessLSKeys ¶
func ProcessLSKeys(keystring, filter string, filtered *elastic.FilteredQuery) ([]lsKeyMatch, error)
This creates the elastic filter porition of a 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 Backends ¶
type Backends struct { TSDBContext opentsdb.Context GraphiteContext graphite.Context LogstashHosts LogstashElasticHosts ElasticHosts ElasticHosts InfluxConfig client.Config }
type BosunProviders ¶
type ESIndexer ¶
type ESIndexer struct { TimeField string Generate func(startDuration, endDuration *time.Time) ([]string, error) }
func (ESIndexer) MarshalJSON ¶
type ESQuery ¶
func (ESQuery) MarshalJSON ¶
type ElasticHosts ¶
type ElasticHosts []string
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
func (ElasticHosts) InitClient ¶
func (e ElasticHosts) InitClient() error
InitClient sets up the elastic client. If the client has already been initalized it is a noop
func (ElasticHosts) Query ¶
func (e ElasticHosts) Query(r *ElasticRequest) (*elastic.SearchResult, error)
Query takes a Logstash request, applies it a search service, and then queries elasticsearch.
type ElasticRequest ¶
type ElasticRequest struct { Indexer ESIndexer 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 ESBaseQuery ¶
func ESBaseQuery(now time.Time, indexer ESIndexer, filter elastic.Query, sduration, eduration string, size int) (*ElasticRequest, error)
ESBaseQuery builds the base query that both ESCount and ESStat share
func (*ElasticRequest) CacheKey ¶
func (r *ElasticRequest) CacheKey() (string, error)
CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache
type Expr ¶
func (*Expr) Execute ¶
func (e *Expr) Execute(backends *Backends, providers *BosunProviders, T miniprofiler.Timer, now time.Time, autods int, unjoinedOk bool) (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 (*Expr) MarshalJSON ¶
type LogstashElasticHosts ¶
type LogstashElasticHosts []string
This 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
func (*LogstashElasticHosts) GenIndices ¶
func (e *LogstashElasticHosts) GenIndices(r *LogstashRequest) (string, error)
GenIndicies generates the indexes to hit based on the timeframe of the query. It assumes all
func (LogstashElasticHosts) InitClient ¶
func (e LogstashElasticHosts) InitClient() error
InitClient sets up the elastic client. If the client has already been initalized it is a noop
func (LogstashElasticHosts) Query ¶
func (e LogstashElasticHosts) Query(r *LogstashRequest) (*elastic.SearchResult, error)
Query takes a Logstash request, applies it a search service, and then queries elasticsearch.
type LogstashRequest ¶
type LogstashRequest struct { IndexRoot string // The root of all index names i.e. logstash in logstash-2014-04-25 Start *time.Time End *time.Time Source *elastic.SearchSource // This the object that we build queries in KeyMatches []lsKeyMatch }
LogstashRequest is a container for the information needed to query elasticsearch.
func LSBaseQuery ¶
func LSBaseQuery(now time.Time, indexRoot string, keystring string, filter, sduration, eduration string, size int) (*LogstashRequest, error)
LSBaseQuery builds the base query that both LSCount and LSStat share
func (*LogstashRequest) CacheKey ¶
func (r *LogstashRequest) CacheKey() string
CacheKey returns the text of the elastic query. That text is the indentifer for the query in the cache
type NumberExpr ¶
type NumberExpr Expr
func (NumberExpr) Type ¶
func (s NumberExpr) Type() models.FuncType
func (NumberExpr) Value ¶
func (s NumberExpr) Value() interface{}
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 DropValues ¶
func ESDateHistogram ¶
func ESIndicies ¶
func ESQueryString ¶
func ESStat ¶
func ESStat(e *State, T miniprofiler.Timer, 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 Forecast_lr ¶
func GraphiteBand ¶
func GraphiteQuery ¶
func InfluxQuery ¶
func LSCount ¶
func LSCount(e *State, T miniprofiler.Timer, index_root, keystring, filter, interval, sduration, eduration string) (r *Results, err error)
LScount takes 6 arguments and returns the per second for matching documents. index_root is the root name of the index to hit, the format is expected to be fmt.Sprintf("%s-%s", index_root, d.Format("2006.01.02")). keystring creates groups (like tagsets) and can also filter those groups. It is the format of "field:regex,field:regex..." The :regex can be ommited. filter is an Elastic regexp query that can be applied to any field. It is in the same format as the keystring argument. interval is in the format of an opentsdb time duration, and tells elastic what the bucket size should be. Note: The results used to be normalized to a per second rate. This is no longer done as it resulted in erroneous extrapolations. sduration and end duration are the time bounds for the query and are in opentsdb's relative time format: http://opentsdb.net/docs/build/html/user_guide/query/dates.html Caveats: 1) There is currently no escaping in the keystring, so if you regex needs to have a comma or double quote you are out of luck. 2) If the type of the field value in Elastic (aka the mapping) is a number then the regexes won't act as a regex. The only thing you can do is an exact match on the number, ie "eventlogid:1234". It is recommended that anything that is a identifer should be stored as a string since they are not numbers even if they are made up entirely of numerals.
func LSDateHistogram ¶
func LSDateHistogram(e *State, T miniprofiler.Timer, index_root, keystring, filter, interval, sduration, eduration, stat_field, rstat string, size int) (r *Results, err error)
LSDateHistorgram builds the aggregation query using subaggregations. The result is a grouped time series that Bosun can understand
func LSStat ¶
func LSStat(e *State, T miniprofiler.Timer, index_root, keystring, filter, field, rstat, interval, sduration, eduration string) (r *Results, err error)
LSStat returns a bucketed statistical reduction for the specified field. The arguments are the same LSCount with the addition of the following: The field is the field to generate stats for - this must be a number type in elastic. rstat is the reduction function to use per bucket and can be one of the following: avg, min, max, sum, sum_of_squares, variance, std_deviation
func Percentile ¶
func SeriesFunc ¶
func ToDuration ¶
type Series ¶
Series is the standard form within bosun to represent timeseries data.
func (Series) MarshalJSON ¶
type SortablePoint ¶
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 *Backends // Bosun Internal *BosunProviders // contains filtered or unexported fields }
func (*State) AddComputation ¶
type Union ¶
type Union struct { models.Computations A, B Value Group opentsdb.TagSet }