Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HoltWinters method #606

Merged
merged 2 commits into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,47 @@ On startup Kapacitor will detect the change and recreate the subscriptions in In
>NOTE: While HTTP itself is a TCP transport such that packet loss shouldn't be an issue, if Kapacitor starts to slow down for whatever reason, InfluxDB will drop the subscription writes to Kapacitor.
In order to know if subscription writes are being dropped you should monitor the measurement `_internal.monitor.subscriber` for the field `writeFailures`.

#### Holt-Winters Forecasting

This release contains an new Holt Winters InfluxQL function.

With this forecasting method one can now define an alert based off forecasted future values.

For example, the following TICKscript will take the last 30 days of disk usage stats and using holt-winters forecast the next 7 days.
If the forecasted value crosses a threshold an alert is triggered.

The result is now Kapacitor will alert you 7 days in advance of a disk filling up.
This assumes a slow growth but by changing the vars in the script you could check for shorter growth intervals.

```
// The interval on which to aggregate the disk usage
var growth_interval = 1d
// The number of `growth_interval`s to forecast into the future
var forecast_count = 7
// The amount of historical data to use for the fit
var history = 30d

// The critical threshold on used_percent
var threshold = 90.0

batch
|query('''
SELECT max(used_percent) as used_percent
FROM "telegraf"."default"."disk"
''')
.period(history)
.every(growth_interval)
.align()
.groupBy(time(growth_interval), *)
|holtWinters('used_percent', forecast_count, 0, growth_interval)
.as('used_percent')
|max('used_percent')
.as('used_percent')
|alert()
// Trigger alert if the forecasted disk usage is greater than threshold
.crit(lambda: "used_percent" > threshold)
```


### Features

Expand All @@ -124,6 +165,7 @@ In order to know if subscription writes are being dropped you should monitor the
- [#416](https://github.com/influxdata/kapacitor/issues/416): Track ingress counts by database, retention policy, and measurement. Expose stats via cli.
- [#586](https://github.com/influxdata/kapacitor/pull/586): Add spread stateful function. thanks @upccup!
- [#600](https://github.com/influxdata/kapacitor/pull/600): Add close http response after handler laert post, thanks @jsvisa!
- [#606](https://github.com/influxdata/kapacitor/pull/606): Add Holt-Winters forecasting method.

### Bugfixes

Expand Down
25 changes: 25 additions & 0 deletions pipeline/influxql.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,28 @@ func (n *chainnode) Elapsed(field string, unit time.Duration) *InfluxQLNode {
n.linkChild(i)
return i
}

// Compute the holt-winters forecast of a data set.
func (n *chainnode) HoltWinters(field string, h, m int64, interval time.Duration) *InfluxQLNode {
return n.holtWinters(field, h, m, interval, false)
}

// Compute the holt-winters forecast of a data set.
func (n *chainnode) HoltWintersWithFit(field string, h, m int64, interval time.Duration) *InfluxQLNode {
return n.holtWinters(field, h, m, interval, true)
}

func (n *chainnode) holtWinters(field string, h, m int64, interval time.Duration, includeFitData bool) *InfluxQLNode {
i := newInfluxQLNode("holt_winters", field, n.Provides(), BatchEdge, ReduceCreater{
CreateFloatReducer: func() (influxql.FloatPointAggregator, influxql.FloatPointEmitter) {
fn := influxql.NewFloatHoltWintersReducer(int(h), int(m), includeFitData, interval)
return fn, fn
},
CreateIntegerFloatReducer: func() (influxql.IntegerPointAggregator, influxql.FloatPointEmitter) {
fn := influxql.NewFloatHoltWintersReducer(int(h), int(m), includeFitData, interval)
return fn, fn
},
})
n.linkChild(i)
return i
}
6 changes: 3 additions & 3 deletions vendor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ vendors:
- path: github.com/davecgh/go-spew
rev: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
- path: github.com/dustin/go-humanize
rev: 88e58c26e9fe8ac578a0d76a68e32838acf17a8d
rev: 499693e27ee0d14ffab67c31ad065fdb3d34ea75
- path: github.com/gogo/protobuf
rev: 7883e1468d48d969e1c3ce4bcde89b6a7dd4adc4
- path: github.com/golang/protobuf
rev: 3b06fc7a4cad73efce5fe6217ab6c33e7231ab4a
- path: github.com/gorhill/cronexpr
rev: f0984319b44273e83de132089ae42b1810f4933b
- path: github.com/influxdata/influxdb
rev: 6e0c5698c1dc33064a1aeb59d0caf8fa88c2edb8
rev: 128b07e352a324c90b48d386cad4efb75f56a0d0
- path: github.com/influxdata/wlog
rev: 7c63b0a71ef8300adc255344d275e10e5c3a71ec
- path: github.com/influxdb/usage-client
Expand All @@ -42,7 +42,7 @@ vendors:
- path: github.com/stretchr/testify
rev: 8d64eb7173c7753d6419fd4a9caf057398611364
- path: github.com/twinj/uuid
rev: 1ec75364d0b109a59493653451144657b8b0698d
rev: 5a4b9dcb2a5e9eaba079cd853d275582fc764505
- path: golang.org/x/crypto
rev: 5bcd134fee4dd1475da17714aac19c0aa0142e2f
- path: golang.org/x/sys
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/dustin/go-humanize/README.markdown

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 64 additions & 47 deletions vendor/github.com/influxdata/influxdb/influxql/functions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading