feat(kapacitor): add option to set noRecoveries on alerts
parent
252f8c4789
commit
77a75a2415
|
@ -5,6 +5,7 @@ import "encoding/json"
|
||||||
// AlertNodes defines all possible kapacitor interactions with an alert.
|
// AlertNodes defines all possible kapacitor interactions with an alert.
|
||||||
type AlertNodes struct {
|
type AlertNodes struct {
|
||||||
IsStateChangesOnly bool `json:"stateChangesOnly"` // IsStateChangesOnly will only send alerts on state changes.
|
IsStateChangesOnly bool `json:"stateChangesOnly"` // IsStateChangesOnly will only send alerts on state changes.
|
||||||
|
IsNoRecoveries bool `json:"noRecoveries"` // IsNoRecoveries will not send alerts when returning to OK state from other states.
|
||||||
UseFlapping bool `json:"useFlapping"` // UseFlapping enables flapping detection. Flapping occurs when a service or host changes state too frequently, resulting in a storm of problem and recovery notification
|
UseFlapping bool `json:"useFlapping"` // UseFlapping enables flapping detection. Flapping occurs when a service or host changes state too frequently, resulting in a storm of problem and recovery notification
|
||||||
Posts []*Post `json:"post"` // HTTPPost will post the JSON alert data to the specified URLs.
|
Posts []*Post `json:"post"` // HTTPPost will post the JSON alert data to the specified URLs.
|
||||||
TCPs []*TCP `json:"tcp"` // TCP will send the JSON alert data to the specified endpoint via TCP.
|
TCPs []*TCP `json:"tcp"` // TCP will send the JSON alert data to the specified endpoint via TCP.
|
||||||
|
|
|
@ -119,6 +119,12 @@ func Trigger(rule chronograf.AlertRule) (string, error) {
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rule.AlertNodes.IsNoRecoveries {
|
||||||
|
trigger += `
|
||||||
|
.noRecoveries()
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
trigger += AllAlerts
|
trigger += AllAlerts
|
||||||
|
|
||||||
if rule.Details != "" {
|
if rule.Details != "" {
|
||||||
|
|
|
@ -145,6 +145,14 @@ export const updateRuleValues = (ruleID, trigger, values) => ({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const updateNoRecoveries = (ruleID, noRecoveries) => ({
|
||||||
|
type: 'UPDATE_RULE_NORECOVERIES',
|
||||||
|
payload: {
|
||||||
|
ruleID,
|
||||||
|
noRecoveries,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export const updateMessage = (ruleID, message) => ({
|
export const updateMessage = (ruleID, message) => ({
|
||||||
type: 'UPDATE_RULE_MESSAGE',
|
type: 'UPDATE_RULE_MESSAGE',
|
||||||
payload: {
|
payload: {
|
||||||
|
|
|
@ -19,6 +19,7 @@ interface HandlerWithText extends Handler {
|
||||||
interface RuleActions {
|
interface RuleActions {
|
||||||
updateAlertNodes: (id: string, handlersOnThisAlert: Handler[]) => void
|
updateAlertNodes: (id: string, handlersOnThisAlert: Handler[]) => void
|
||||||
updateMessage: (id: string, e: MouseEvent<HTMLInputElement>) => void
|
updateMessage: (id: string, e: MouseEvent<HTMLInputElement>) => void
|
||||||
|
updateNoRecoveries: (id: string, noRecoveries: boolean) => void
|
||||||
updateDetails: () => void
|
updateDetails: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +122,8 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
: 'Add a Handler'
|
: 'Add a Handler'
|
||||||
|
|
||||||
const ruleSectionClassName = handlersOnThisAlert.length
|
const ruleSectionClassName = handlersOnThisAlert.length
|
||||||
? 'rule-section--row rule-section--row-first rule-section--border-bottom'
|
? 'rule-section--row rule-section--border-bottom'
|
||||||
: 'rule-section--row rule-section--row-first rule-section--row-last'
|
: 'rule-section--row rule-section--row-last'
|
||||||
|
|
||||||
const selectedHandlerWithText: HandlerWithText = this.addNicknameText(
|
const selectedHandlerWithText: HandlerWithText = this.addNicknameText(
|
||||||
selectedHandler
|
selectedHandler
|
||||||
|
@ -132,6 +133,18 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
<div className="rule-section">
|
<div className="rule-section">
|
||||||
<h3 className="rule-section--heading">Alert Handlers</h3>
|
<h3 className="rule-section--heading">Alert Handlers</h3>
|
||||||
<div className="rule-section--body">
|
<div className="rule-section--body">
|
||||||
|
<div className="rule-section--row rule-section--row-first rule-section--border-bottom">
|
||||||
|
<div className="form-control-static handler-checkbox">
|
||||||
|
<input
|
||||||
|
name="noRecoveries"
|
||||||
|
id="noRecoveries"
|
||||||
|
type="checkbox"
|
||||||
|
defaultChecked={rule.alertNodes.noRecoveries}
|
||||||
|
onClick={this.handleNoRecoveries}
|
||||||
|
/>
|
||||||
|
<label htmlFor="noRecoveries">Don't send alert on condition recovery</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className={ruleSectionClassName}>
|
<div className={ruleSectionClassName}>
|
||||||
<p>Send this Alert to:</p>
|
<p>Send this Alert to:</p>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
@ -166,6 +179,11 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleNoRecoveries = (e) {
|
||||||
|
const {ruleActions, rule} = this.props
|
||||||
|
ruleActions.updateNoRecoveries(rule.id, e.target.checked)
|
||||||
|
}
|
||||||
|
|
||||||
private handleChooseHandler = (ep: HandlerWithText): (() => void) => () => {
|
private handleChooseHandler = (ep: HandlerWithText): (() => void) => () => {
|
||||||
this.setState({selectedHandler: ep})
|
this.setState({selectedHandler: ep})
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,15 @@ export default function rules(state = {}, action) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'UPDATE_RULE_NORECOVERIES': {
|
||||||
|
const {ruleID, noRecoveries} = action.payload
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
[ruleID]: Object.assign({}, state[ruleID], {
|
||||||
|
alertNodes: {...state[ruleID].alertNodes, noRecoveries: noRecoveries}
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
case 'UPDATE_RULE_ALERT_NODES': {
|
case 'UPDATE_RULE_ALERT_NODES': {
|
||||||
const {ruleID, alerts} = action.payload
|
const {ruleID, alerts} = action.payload
|
||||||
const alertNodesByType = {}
|
const alertNodesByType = {}
|
||||||
|
|
|
@ -122,6 +122,7 @@ type TICKScript = string
|
||||||
// AlertNodes defines all possible kapacitor interactions with an alert.
|
// AlertNodes defines all possible kapacitor interactions with an alert.
|
||||||
interface AlertNodes {
|
interface AlertNodes {
|
||||||
stateChangesOnly: boolean
|
stateChangesOnly: boolean
|
||||||
|
noRecoveries: boolean
|
||||||
useFlapping: boolean
|
useFlapping: boolean
|
||||||
post: Post[]
|
post: Post[]
|
||||||
tcp: TCP[]
|
tcp: TCP[]
|
||||||
|
|
Loading…
Reference in New Issue