diff --git a/notification/rule/http.go b/notification/rule/http.go index f8f9348419..fd8899b4d4 100644 --- a/notification/rule/http.go +++ b/notification/rule/http.go @@ -32,7 +32,7 @@ func (s *HTTP) GenerateFlux(e influxdb.NotificationEndpoint) (string, error) { func (s *HTTP) GenerateFluxAST(e *endpoint.HTTP) (*ast.Package, error) { f := flux.File( s.Name, - flux.Imports("influxdata/influxdb/monitor", "http", "json", "experimental"), + flux.Imports("influxdata/influxdb/monitor", "http", "json", "experimental", "influxdata/influxdb/v1"), s.generateFluxASTBody(e), ) return &ast.Package{Package: "main", Files: []*ast.File{f}}, nil diff --git a/notification/rule/http_test.go b/notification/rule/http_test.go index 773cd431f2..a59328431b 100644 --- a/notification/rule/http_test.go +++ b/notification/rule/http_test.go @@ -16,6 +16,7 @@ import "influxdata/influxdb/monitor" import "http" import "json" import "experimental" +import "influxdata/influxdb/v1" option task = {name: "foo", every: 2h, offset: 1s} @@ -28,6 +29,7 @@ notification = { } statuses = monitor.from(start: -2h, fn: (r) => (r.foo == "bar" and r.baz == "bang")) + |> v1.fieldsAsCols() any_to_crit = statuses |> monitor.stateChanges(fromLevel: "any", toLevel: "crit") all_statuses = any_to_crit diff --git a/notification/rule/rule.go b/notification/rule/rule.go index 78cf0c0721..d6a759eb69 100644 --- a/notification/rule/rule.go +++ b/notification/rule/rule.go @@ -263,7 +263,10 @@ func (b *Base) generateFluxASTStatuses() ast.Statement { props = append(props, flux.Property("fn", flux.Function(flux.FunctionParams("r"), body))) } - base := flux.Call(flux.Member("monitor", "from"), flux.Object(props...)) + base := flux.Pipe( + flux.Call(flux.Member("monitor", "from"), flux.Object(props...)), + flux.Call(flux.Member("v1", "fieldsAsCols"), flux.Object()), + ) return flux.DefineVariable("statuses", base) } diff --git a/notification/rule/slack.go b/notification/rule/slack.go index 252920e5aa..80c0e787e2 100644 --- a/notification/rule/slack.go +++ b/notification/rule/slack.go @@ -34,7 +34,7 @@ func (s *Slack) GenerateFlux(e influxdb.NotificationEndpoint) (string, error) { func (s *Slack) GenerateFluxAST(e *endpoint.Slack) (*ast.Package, error) { f := flux.File( s.Name, - flux.Imports("influxdata/influxdb/monitor", "slack", "influxdata/influxdb/secrets", "experimental"), + flux.Imports("influxdata/influxdb/monitor", "slack", "influxdata/influxdb/secrets", "experimental", "influxdata/influxdb/v1"), s.generateFluxASTBody(e), ) return &ast.Package{Package: "main", Files: []*ast.File{f}}, nil diff --git a/notification/rule/slack_test.go b/notification/rule/slack_test.go index 372aae88fe..3062dd0262 100644 --- a/notification/rule/slack_test.go +++ b/notification/rule/slack_test.go @@ -30,6 +30,7 @@ import "influxdata/influxdb/monitor" import "slack" import "influxdata/influxdb/secrets" import "experimental" +import "influxdata/influxdb/v1" option task = {name: "foo", every: 2h} @@ -43,6 +44,7 @@ notification = { } statuses = monitor.from(start: -2h, fn: (r) => (r.foo == "bar" and r.baz == "bang")) + |> v1.fieldsAsCols() any_to_crit = statuses |> monitor.stateChanges(fromLevel: "any", toLevel: "crit") info_to_warn = statuses