Documentation ¶
Index ¶
- Variables
- func ProcessLSKeys(keystring, filter string, filtered *elastic.FilteredQuery) ([]lsKeyMatch, error)
- type AlertKey
- type AlertKeys
- type AlertStatusProvider
- type Computation
- type Computations
- type Expr
- func (e *Expr) Execute(c opentsdb.Context, g graphite.Context, l LogstashElasticHosts, ...) (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 Result
- type ResultSlice
- type ResultSliceByGroup
- type ResultSliceByValue
- type Results
- func Abs(e *State, T miniprofiler.Timer, series *Results) *Results
- 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 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 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 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 Length(e *State, T miniprofiler.Timer, series *Results) (*Results, error)
- func Limit(e *State, T miniprofiler.Timer, series *Results, v float64) (*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 Min(e *State, T miniprofiler.Timer, series *Results) (r *Results, err error)
- func NV(e *State, T miniprofiler.Timer, series *Results, v float64) (results *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 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 Transpose(e *State, T miniprofiler.Timer, d *Results, gp string) (*Results, error)
- func Ungroup(e *State, T miniprofiler.Timer, d *Results) (*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 Union
- type Value
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownOp = fmt.Errorf("expr: unknown op type")
var Graphite = map[string]parse.Func{ "graphiteBand": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeScalar}, Return: parse.TypeSeriesSet, Tags: graphiteTagQuery, F: GraphiteBand, }, "graphite": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeSeriesSet, Tags: graphiteTagQuery, F: GraphiteQuery, }, }
Graphite defines functions for use with a Graphite backend.
var Influx = map[string]parse.Func{ "influx": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeSeriesSet, Tags: influxTag, F: InfluxQuery, }, }
Influx is a map of functions to query InfluxDB.
var LogstashElastic = map[string]parse.Func{ "lscount": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeSeriesSet, Tags: logstashTagQuery, F: LSCount, }, "lsstat": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.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: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeScalar}, Return: parse.TypeSeriesSet, Tags: tagQuery, F: Band, }, "change": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeNumberSet, Tags: tagQuery, F: Change, }, "count": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeScalar, F: Count, }, "q": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString}, Return: parse.TypeSeriesSet, Tags: tagQuery, F: Query, }, "window": { Args: []parse.FuncType{parse.TypeString, parse.TypeString, parse.TypeString, parse.TypeScalar, parse.TypeString}, Return: parse.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 AlertKey ¶
type AlertKey string
func ParseAlertKey ¶
type AlertStatusProvider ¶
type AlertStatusProvider interface {
GetUnknownAndUnevaluatedAlertKeys(alertName string) (unknown, unevaluated []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 Computation ¶
type Computation struct { Text string Value interface{} }
type Computations ¶
type Computations []Computation
type Expr ¶
func (*Expr) Execute ¶
func (e *Expr) Execute(c opentsdb.Context, g graphite.Context, l LogstashElasticHosts, influxConfig client.Config, cache *cache.Cache, T miniprofiler.Timer, now time.Time, autods int, unjoinedOk bool, search *search.Search, squelched func(tags opentsdb.TagSet) bool, history AlertStatusProvider) (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, l LogstashElasticHosts, 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 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 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. The result will be normalized to a per second rate regardless of what this is set to. 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 timer 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 ¶
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 // OpenTSDB Search *search.Search // InfluxDB InfluxConfig client.Config History AlertStatusProvider // contains filtered or unexported fields }
func (*State) AddComputation ¶
type Union ¶
type Union struct { Computations A, B Value Group opentsdb.TagSet }