fix(notification/rule): pivot table from monitor
parent
07e7309c48
commit
5ff6f8b9ca
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue