fix(notification/rule): pagerduty helper functions need key ar… (#15047)

fix(notification/rule): pagerduty helper functions need key args
pull/15048/head
Chris Goller 2019-09-06 22:00:45 -05:00 committed by GitHub
commit 55e124735c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 18 deletions

View File

@ -113,16 +113,6 @@ func Call(fn ast.Expression, args *ast.ObjectExpression) *ast.CallExpression {
}
}
// DirectCall returns a *ast.CallExpression that is a function call of fn with args.
func DirectCall(fn ast.Expression, args ast.Expression) *ast.CallExpression {
return &ast.CallExpression{
Callee: fn,
Arguments: []ast.Expression{
args,
},
}
}
// ExpressionStatement returns an *ast.ExpressionStagement of e.
func ExpressionStatement(e ast.Expression) *ast.ExpressionStatement {
return &ast.ExpressionStatement{Expression: e}

View File

@ -150,7 +150,7 @@ func (s *PagerDuty) generateFluxASTNotifyPipe(url string) ast.Statement {
// required
// string
// The unique location of the affected system, preferably a hostname or FQDN
endpointProps = append(endpointProps, flux.Property("source", flux.Member("r", "_notification_rule_name")))
endpointProps = append(endpointProps, flux.Property("source", flux.Member("notification", "_notification_rule_name")))
// summary:
// required
@ -177,16 +177,20 @@ func (s *PagerDuty) generateFluxASTNotifyPipe(url string) ast.Statement {
}
func severityFromLevel() *ast.CallExpression {
return flux.DirectCall(
return flux.Call(
flux.Member("pagerduty", "severityFromLevel"),
flux.Member("r", "_level"),
flux.Object(
flux.Property("level", flux.Member("r", "_level")),
),
)
}
func actionFromLevel() *ast.CallExpression {
return flux.DirectCall(
return flux.Call(
flux.Member("pagerduty", "actionFromLevel"),
flux.Member("r", "_level"),
flux.Object(
flux.Property("level", flux.Member("r", "_level")),
),
)
}

View File

@ -37,9 +37,9 @@ statuses
clientURL: "http://localhost:7777",
class: r._check_name,
group: r._source_measurement,
severity: pagerduty.severityFromLevel(r._level),
eventAction: pagerduty.actionFromLevel(r._level),
source: r._notification_rule_name,
severity: pagerduty.severityFromLevel(level: r._level),
eventAction: pagerduty.actionFromLevel(level: r._level),
source: notification._notification_rule_name,
summary: r._message,
timestamp: time(v: r._source_timestamp),
})))`