Add exec kapacitor rule alert support.
parent
b06b141dde
commit
54f66b43de
|
@ -4,14 +4,16 @@ import ReactTooltip from 'react-tooltip';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import {RULE_MESSAGE_TEMPLATES as templates} from '../constants/index.js';
|
import {RULE_MESSAGE_TEMPLATES as templates} from '../constants/index.js';
|
||||||
|
|
||||||
const DEFAULT_ALERTS = ['http', 'tcp'];
|
const DEFAULT_ALERTS = ['http', 'tcp', 'exec'];
|
||||||
const DEFAULT_ALERT_PLACEHOLDERS = {
|
const DEFAULT_ALERT_PLACEHOLDERS = {
|
||||||
http: 'URL',
|
http: 'URL',
|
||||||
tcp: 'Address',
|
tcp: 'Address',
|
||||||
|
exec: 'Add command with arguments separated by spaces',
|
||||||
};
|
};
|
||||||
const ALERT_NODES_ACCESSORS = {
|
const ALERT_NODES_ACCESSORS = {
|
||||||
http: 'alertNodes[0].args[0]',
|
http: (rule) => _.get(rule, 'alertNodes[0].args[0]', ''),
|
||||||
tcp: 'alertNodes[0].args[0]',
|
tcp: (rule) => _.get(rule, 'alertNodes[0].args[0]', ''),
|
||||||
|
exec: (rule) => _.get(rule, 'alertNodes[0].args', []).join(' '),
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -118,7 +120,7 @@ export const RuleMessage = React.createClass({
|
||||||
placeholder={DEFAULT_ALERT_PLACEHOLDERS[alert]}
|
placeholder={DEFAULT_ALERT_PLACEHOLDERS[alert]}
|
||||||
ref={(r) => this.selectedAlertProperty = r}
|
ref={(r) => this.selectedAlertProperty = r}
|
||||||
onChange={() => updateAlertNodes(rule.id, alert, this.selectedAlertProperty.value)}
|
onChange={() => updateAlertNodes(rule.id, alert, this.selectedAlertProperty.value)}
|
||||||
value={_.get(rule, ALERT_NODES_ACCESSORS[alert], '')}
|
value={ALERT_NODES_ACCESSORS[alert](rule)}
|
||||||
/>);
|
/>);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -100,6 +100,15 @@ export default function rules(state = {}, action) {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case 'exec':
|
||||||
|
alertNodesByType = [
|
||||||
|
{
|
||||||
|
name: 'exec',
|
||||||
|
args: alertNodesText.split(' '),
|
||||||
|
properties: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
alertNodesByType = [];
|
alertNodesByType = [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue