Skip to content

Commit

Permalink
fix(notification/rule): Include the edge of the boundary we are obser…
Browse files Browse the repository at this point in the history
…ving.
  • Loading branch information
brettbuddin committed Aug 24, 2020
1 parent 521500b commit 7672258
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions notification/rule/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: endpoint(mapFn: (r) => {
Expand Down Expand Up @@ -102,7 +102,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: endpoint(mapFn: (r) => {
Expand Down Expand Up @@ -177,7 +177,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: endpoint(mapFn: (r) => {
Expand Down Expand Up @@ -250,7 +250,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 5s)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 5s)))
all_statuses
|> monitor["notify"](data: notification, endpoint: endpoint(mapFn: (r) => {
Expand Down
6 changes: 3 additions & 3 deletions notification/rule/pagerduty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: pagerduty_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -166,7 +166,7 @@ info_to_crit = statuses
|> monitor["stateChanges"](fromLevel: "info", toLevel: "crit")
all_statuses = info_to_crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: pagerduty_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -256,7 +256,7 @@ ok_to_warn = statuses
all_statuses = union(tables: [crit, ok_to_warn])
|> sort(columns: ["_time"])
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: pagerduty_endpoint(mapFn: (r) =>
Expand Down
9 changes: 5 additions & 4 deletions notification/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,17 @@ func (b *Base) generateLevelChecks() []ast.Statement {
now := flux.Call(flux.Identifier("now"), flux.Object())
timeFilter := flux.Function(
flux.FunctionParams("r"),
flux.GreaterThan(
flux.Member("r", "_time"),
flux.Call(
&ast.BinaryExpression{
Operator: ast.GreaterThanEqualOperator,
Left: flux.Member("r", "_time"),
Right: flux.Call(
flux.Member("experimental", "subDuration"),
flux.Object(
flux.Property("from", now),
flux.Property("d", (*ast.DurationLiteral)(b.Every)),
),
),
),
},
)

var pipe *ast.PipeExpression
Expand Down
8 changes: 4 additions & 4 deletions notification/rule/slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ any = statuses
(true))
all_statuses = any
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: slack_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -133,7 +133,7 @@ info_to_warn = statuses
all_statuses = union(tables: [crit, info_to_warn])
|> sort(columns: ["_time"])
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: slack_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -210,7 +210,7 @@ info_to_warn = statuses
all_statuses = union(tables: [crit, info_to_warn])
|> sort(columns: ["_time"])
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: slack_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -289,7 +289,7 @@ info_to_warn = statuses
all_statuses = union(tables: [crit, info_to_warn])
|> sort(columns: ["_time"])
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: slack_endpoint(mapFn: (r) =>
Expand Down
4 changes: 2 additions & 2 deletions notification/rule/telegram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ crit = statuses
(r["_level"] == "crit"))
all_statuses = crit
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: telegram_endpoint(mapFn: (r) =>
Expand Down Expand Up @@ -197,7 +197,7 @@ any = statuses
(true))
all_statuses = any
|> filter(fn: (r) =>
(r["_time"] > experimental["subDuration"](from: now(), d: 1h)))
(r["_time"] >= experimental["subDuration"](from: now(), d: 1h)))
all_statuses
|> monitor["notify"](data: notification, endpoint: telegram_endpoint(mapFn: (r) =>
Expand Down

0 comments on commit 7672258

Please sign in to comment.