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.
|
||||
type AlertNodes struct {
|
||||
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
|
||||
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.
|
||||
|
|
|
@ -119,6 +119,12 @@ func Trigger(rule chronograf.AlertRule) (string, error) {
|
|||
`
|
||||
}
|
||||
|
||||
if rule.AlertNodes.IsNoRecoveries {
|
||||
trigger += `
|
||||
.noRecoveries()
|
||||
`
|
||||
}
|
||||
|
||||
trigger += AllAlerts
|
||||
|
||||
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) => ({
|
||||
type: 'UPDATE_RULE_MESSAGE',
|
||||
payload: {
|
||||
|
|
|
@ -19,6 +19,7 @@ interface HandlerWithText extends Handler {
|
|||
interface RuleActions {
|
||||
updateAlertNodes: (id: string, handlersOnThisAlert: Handler[]) => void
|
||||
updateMessage: (id: string, e: MouseEvent<HTMLInputElement>) => void
|
||||
updateNoRecoveries: (id: string, noRecoveries: boolean) => void
|
||||
updateDetails: () => void
|
||||
}
|
||||
|
||||
|
@ -121,8 +122,8 @@ class RuleHandlers extends PureComponent<Props, State> {
|
|||
: 'Add a Handler'
|
||||
|
||||
const ruleSectionClassName = handlersOnThisAlert.length
|
||||
? 'rule-section--row rule-section--row-first rule-section--border-bottom'
|
||||
: 'rule-section--row rule-section--row-first rule-section--row-last'
|
||||
? 'rule-section--row rule-section--border-bottom'
|
||||
: 'rule-section--row rule-section--row-last'
|
||||
|
||||
const selectedHandlerWithText: HandlerWithText = this.addNicknameText(
|
||||
selectedHandler
|
||||
|
@ -132,6 +133,18 @@ class RuleHandlers extends PureComponent<Props, State> {
|
|||
<div className="rule-section">
|
||||
<h3 className="rule-section--heading">Alert Handlers</h3>
|
||||
<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}>
|
||||
<p>Send this Alert to:</p>
|
||||
<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) => () => {
|
||||
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': {
|
||||
const {ruleID, alerts} = action.payload
|
||||
const alertNodesByType = {}
|
||||
|
|
|
@ -122,6 +122,7 @@ type TICKScript = string
|
|||
// AlertNodes defines all possible kapacitor interactions with an alert.
|
||||
interface AlertNodes {
|
||||
stateChangesOnly: boolean
|
||||
noRecoveries: boolean
|
||||
useFlapping: boolean
|
||||
post: Post[]
|
||||
tcp: TCP[]
|
||||
|
|
Loading…
Reference in New Issue