Skip to content

Commit

Permalink
cmd/bosun: Add dropl and dropg
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebrandt committed Jul 7, 2015
1 parent 163ea92 commit e1e02ea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/bosun/expr/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,24 @@ var builtins = map[string]parse.Func{
Tags: tagFirst,
F: DropGe,
},
"dropg": {
Args: []parse.FuncType{parse.TypeSeriesSet, parse.TypeScalar},
Return: parse.TypeSeriesSet,
Tags: tagFirst,
F: DropG,
},
"drople": {
Args: []parse.FuncType{parse.TypeSeriesSet, parse.TypeScalar},
Return: parse.TypeSeriesSet,
Tags: tagFirst,
F: DropLe,
},
"dropl": {
Args: []parse.FuncType{parse.TypeSeriesSet, parse.TypeScalar},
Return: parse.TypeSeriesSet,
Tags: tagFirst,
F: DropL,
},
"dropna": {
Args: []parse.FuncType{parse.TypeSeriesSet},
Return: parse.TypeSeriesSet,
Expand Down Expand Up @@ -390,11 +402,21 @@ func DropGe(e *State, T miniprofiler.Timer, series *Results, threshold float64)
return DropValues(e, T, series, threshold, dropFunction)
}

func DropG(e *State, T miniprofiler.Timer, series *Results, threshold float64) (*Results, error) {
dropFunction := func(value float64, threshold float64) bool { return value > threshold }
return DropValues(e, T, series, threshold, dropFunction)
}

func DropLe(e *State, T miniprofiler.Timer, series *Results, threshold float64) (*Results, error) {
dropFunction := func(value float64, threshold float64) bool { return value <= threshold }
return DropValues(e, T, series, threshold, dropFunction)
}

func DropL(e *State, T miniprofiler.Timer, series *Results, threshold float64) (*Results, error) {
dropFunction := func(value float64, threshold float64) bool { return value < threshold }
return DropValues(e, T, series, threshold, dropFunction)
}

func DropNA(e *State, T miniprofiler.Timer, series *Results) (*Results, error) {
dropFunction := func(value float64, threshold float64) bool {
return math.IsNaN(float64(value)) || math.IsInf(float64(value), 0)
Expand Down
9 changes: 9 additions & 0 deletions docs/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,23 @@ Returns series smoothed using Holt-Winters double exponential smoothing. Alpha
(scalar) is the data smoothing factor. Beta (scalar) is the trend smoothing
factor.

## dropg(seriesSet, scalar) seriesSet

Remove any values greater than number from a series. Will error if this operation results in an empty series.

## dropge(seriesSet, scalar) seriesSet

Remove any values greater than or equal to number from a series. Will error if this operation results in an empty series.

## dropl(seriesSet, scalar) seriesSet

Remove any values lower than number from a series. Will error if this operation results in an empty series.

## drople(seriesSet, scalar) seriesSet

Remove any values lower than or equal to number from a series. Will error if this operation results in an empty series.


## dropna(seriesSet) seriesSet

Remove any NaN or Inf values from a series. Will error if this operation results in an empty series.
Expand Down

0 comments on commit e1e02ea

Please sign in to comment.