From 177d394e761ce7a6ac1ee295dd653f0d98495b51 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Mon, 31 Oct 2016 11:11:34 -0700 Subject: [PATCH] Add Sensu config --- ui/src/kapacitor/components/AlertOutputs.js | 12 +++- ui/src/kapacitor/components/SensuConfig.js | 63 +++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 ui/src/kapacitor/components/SensuConfig.js diff --git a/ui/src/kapacitor/components/AlertOutputs.js b/ui/src/kapacitor/components/AlertOutputs.js index f63c054bd1..c10b95ae8c 100644 --- a/ui/src/kapacitor/components/AlertOutputs.js +++ b/ui/src/kapacitor/components/AlertOutputs.js @@ -4,6 +4,7 @@ import {getKapacitorConfig, updateKapacitorConfigSection, testAlertOutput} from import AlertaConfig from './AlertaConfig'; import HipchatConfig from './HipchatConfig'; import PagerdutyConfig from './PagerdutyConfig'; +import SensuConfig from './SensuConfig'; import SlackConfig from './SlackConfig'; import SMTPConfig from './SMTPConfig'; import TelegramConfig from './TelegramConfig'; @@ -30,6 +31,7 @@ const AlertOutputs = React.createClass({ slackConfig: null, telegramConfig: null, hipchatConfig: null, + sensuConfig: null, }; }, @@ -47,6 +49,7 @@ const AlertOutputs = React.createClass({ smtpConfig: this.getSection(sections, 'smtp'), telegramConfig: this.getSection(sections, 'telegram'), victoropsConfig: this.getSection(sections, 'victorops'), + sensuConfig: this.getSection(sections, 'sensu'), }); }); }, @@ -99,6 +102,7 @@ const AlertOutputs = React.createClass({ + @@ -142,11 +146,15 @@ const AlertOutputs = React.createClass({ return ; } - if (endpoint === 'hipchat' && this.state.pagerdutyConfig) { + if (endpoint === 'hipchat' && this.state.hipchatConfig) { return ; } - return
This endpoint is not supported yet!
; + if (endpoint === 'sensu' && this.state.sensuConfig) { + return ; + } + + return
; }, }); diff --git a/ui/src/kapacitor/components/SensuConfig.js b/ui/src/kapacitor/components/SensuConfig.js new file mode 100644 index 0000000000..e637d8d0fa --- /dev/null +++ b/ui/src/kapacitor/components/SensuConfig.js @@ -0,0 +1,63 @@ +import React, {PropTypes} from 'react'; + +const SensuConfig = React.createClass({ + propTypes: { + config: PropTypes.shape({ + options: PropTypes.shape({ + source: PropTypes.string.isRequired, + addr: PropTypes.string.isRequired, + }).isRequired, + }).isRequired, + onSave: PropTypes.func.isRequired, + }, + + handleSaveAlert(e) { + e.preventDefault(); + + const properties = { + source: this.source.value, + addr: this.addr.value, + }; + + this.props.onSave(properties); + }, + + render() { + const {source, addr} = this.props.config.options; + + return ( +
+

Alerta Alert

+
+
+
+
+

+ Have alerts sent to Sensu +

+ +
+ + this.source = r} defaultValue={source || ''}> +
+ +
+ + this.addr = r} defaultValue={addr || ''}> +
+
+
+ +
+
+
+ +
+
+
+
+ ); + }, +}); + +export default SensuConfig;