Skip to content

Commit

Permalink
Add googlechat_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
nsano-rururu committed Oct 12, 2022
1 parent 3d35e76 commit d74fd50
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/components/config/alert/ConfigAlertGoogleChat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
<label>URL to Kibana to include in the card footer.</label>
</praeco-form-item>
</div>

<praeco-form-item label="Proxy" prop="googleChatProxy">
<el-input id="googleChatProxy" v-model="googleChatProxy" :disabled="viewOnly" />
<label>
By default ElastAlert 2 will not use a network proxy to send notifications to GoogleChat.
Set this option using hostname:port if you need to use a proxy.
</label>
</praeco-form-item>
</div>
</template>

Expand Down Expand Up @@ -115,6 +123,18 @@ export default {
value
);
}
},
googleChatProxy: {
get() {
return this.$store.state.config.alert.googleChatProxy;
},
set(value) {
this.$store.commit(
'config/alert/UPDATE_GOOGLECHAT_PROXY',
value
);
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions src/store/config/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function initialState() {
googleChatHeaderSubtitle: '',
googleChatHeaderImage: '',
googleFooterKibanalink: '',
googleChatProxy: '',

/* Mattermost */
mattermostChannelOverride: '',
Expand Down Expand Up @@ -1216,6 +1217,10 @@ export default {
state.googleFooterKibanalink = googleFooterKibanalink;
},

UPDATE_GOOGLECHAT_PROXY(state, googleChatProxy) {
state.googleChatProxy = googleChatProxy;
},

/* Mattermost */
UPDATE_MATTERMOST_CHANNEL_OVERRIDE(state, mattermostChannelOverride) {
state.mattermostChannelOverride = mattermostChannelOverride;
Expand Down
6 changes: 5 additions & 1 deletion src/store/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ export default {
commit('alert/OPSGENIE_SUBJECT', config.opsgenie_subject);
commit('alert/OPSGENIE_ALIAS', config.opsgenie_alias);
commit('alert/OPSGENIE_PROXY', config.opsgenie_proxy);
commit('alert/OPSGENIE_PRIORITY', config.opsgenie_priority);
commit('alert/OPSGENIE_DESCRIPTION', config.opsgenie_description);

// TODO: opsgenie_priority
Expand Down Expand Up @@ -653,6 +652,7 @@ export default {
commit('alert/UPDATE_GOOGLECHAT_HEADER_SUBTITLE', config.googlechat_header_subtitle);
commit('alert/UPDATE_GOOGLECHAT_HEADER_IMAGE', config.googlechat_header_image);
commit('alert/UPDATE_GOOGLECHAT_FOOTER_KIBANALINK', config.googlechat_footer_kibanalink);
commit('alert/UPDATE_GOOGLECHAT_PROXY', config.googlechat_proxy);

/* Mattermost */
commit('alert/UPDATE_MATTERMOST_CHANNEL_OVERRIDE', config.mattermost_channel_override);
Expand Down Expand Up @@ -2369,6 +2369,10 @@ export default {
config.googlechat_footer_kibanalink = state.alert.googleFooterKibanalink;
}

if (state.alert.googleChatProxy) {
config.googlechat_proxy = state.alert.googleChatProxy;
}

return config;
},

Expand Down
1 change: 1 addition & 0 deletions tests/unit/mockData/alert/ruleDataGoogleChat002.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ googlechat_format: card
googlechat_header_image: http://example/abc.png
googlechat_header_subtitle: b
googlechat_header_title: a
googlechat_proxy: hostname:8080
googlechat_webhook_url: http://example/abca
import: BaseRule.config
index: hannibal-*
Expand Down
1 change: 1 addition & 0 deletions tests/unit/specs/alert/ConfigYamlGoogleChat002.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ googlechat_format: "card"
googlechat_header_image: "http://example/abc.png"
googlechat_header_subtitle: "b"
googlechat_header_title: "a"
googlechat_proxy: "hostname:8080"
googlechat_webhook_url: "http://example/abca"
import: "BaseRule.config"
index: "hannibal-*"
Expand Down

0 comments on commit d74fd50

Please sign in to comment.