Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: johnsusek/praeco
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: abirsigron/praeco
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Sep 9, 2020

  1. Copy the full SHA
    a4b2f2c View commit details
Showing with 114 additions and 1 deletion.
  1. +67 −0 src/components/config/alert/ConfigAlert.vue
  2. +18 −0 src/store/config/alert.js
  3. +29 −1 src/store/config/index.js
67 changes: 67 additions & 0 deletions src/components/config/alert/ConfigAlert.vue
Original file line number Diff line number Diff line change
@@ -35,6 +35,37 @@
</el-col>
</el-row>

<el-row :gutter="19">
<el-col :span="6">
<el-form-item label="Use Time Window">
<el-switch v-model="useTimeWindow" :disabled="viewOnly" @change="changeTimeWindow" />
<label>
Use time window abir continue here
</label>
</el-form-item>
</el-col>
<el-col v-show="useTimeWindow" :span="6">
<el-form-item label="Start time" :required="useTimeWindow">
<el-input v-model="timeWindowStartTime" />
<label v-if="!viewOnly">Start time of the range.</label>
</el-form-item>
</el-col>
<el-col v-show="useTimeWindow" :span="6">
<el-form-item label="End time" :required="useTimeWindow">
<el-input v-model="timeWindowEndTime" />
<label v-if="!viewOnly">Start time of the range.</label>
</el-form-item>
</el-col>
<el-col v-show="useTimeWindow" :span="6">
<el-form-item label="Drop if" prop="timeWindowDropIf" :required="useTimeWindow">
<el-select v-model="timeWindowDropIf" :disabled="viewOnly" placeholder="" class="el-select-wide">
<el-option key="outside" label="Outside" value="outside" />
<el-option key="inside" label="Inside" value="inside" />
</el-select>
<label v-if="!viewOnly">Drop if inside/outside given range.</label>
</el-form-item>
</el-col>
</el-row>
<el-form-item
v-if="!viewOnly"
:label="`Destination${alert.length > 1 ? 's' : ''}`"
@@ -910,6 +941,39 @@ export default {
}
},
useTimeWindow: {
get() {
return this.$store.state.config.alert.useTimeWindow;
},
set(value) {
this.$store.commit('config/alert/UPDATE_USE_TIME_WINDOW', value);
}
},
timeWindowStartTime: {
get() {
return this.$store.state.config.alert.timeWindowStartTime;
},
set(value) {
this.$store.commit('config/alert/UPDATE_TIME_WINDOW_START_TIME', value);
}
},
timeWindowEndTime: {
get() {
return this.$store.state.config.alert.timeWindowEndTime;
},
set(value) {
this.$store.commit('config/alert/UPDATE_TIME_WINDOW_END_TIME', value);
}
},
timeWindowDropIf: {
get() {
return this.$store.state.config.alert.timeWindowDropIf;
},
set(value) {
this.$store.commit('config/alert/UPDATE_TIME_WINDOW_DROP_IF', value);
}
},
gitterMsgLevel: {
get() {
return this.$store.state.config.alert.gitterMsgLevel;
@@ -1062,6 +1126,9 @@ export default {
},
methods: {
changeTimeWindow(val) {
},
addEmoji(value) {
this.slackEmojiOverride = value.colons;
},
18 changes: 18 additions & 0 deletions src/store/config/alert.js
Original file line number Diff line number Diff line change
@@ -51,6 +51,11 @@ function initialState() {
command: [],
gitterMsgLevel: 'error',

useTimeWindow: false,
timeWindowStartTime: '',
timeWindowEndTime: '',
timeWindowDropIf: '',

jiraProject: '',
jiraIssueType: '',
jiraComponents: '',
@@ -245,6 +250,19 @@ export default {
state.gitterMsgLevel = gitterMsgLevel;
},

UPDATE_USE_TIME_WINDOW(state, useTimeWindow) {
state.useTimeWindow = useTimeWindow;
},
UPDATE_TIME_WINDOW_START_TIME(state, timeWindowStartTime) {
state.timeWindowStartTime = timeWindowStartTime;
},
UPDATE_TIME_WINDOW_END_TIME(state, timeWindowEndTime) {
state.timeWindowEndTime = timeWindowEndTime;
},
UPDATE_TIME_WINDOW_DROP_IF(state, timeWindowDropIf) {
state.timeWindowDropIf = timeWindowDropIf;
},

UPDATE_JIRA_PROJECT(state, jiraProject) {
state.jiraProject = jiraProject;
},
30 changes: 29 additions & 1 deletion src/store/config/index.js
Original file line number Diff line number Diff line change
@@ -245,6 +245,14 @@ export default {

commit('alert/UPDATE_GITTER_MSG_LEVEL', config.gitter_msg_level);

if (config.start_time && config.end_time && config.drop_if) {
commit('alert/UPDATE_USE_TIME_WINDOW', true);
commit('alert/UPDATE_TIME_WINDOW_START_TIME', config.start_time);
commit('alert/UPDATE_TIME_WINDOW_END_TIME', config.end_time);
commit('alert/UPDATE_TIME_WINDOW_DROP_IF', config.drop_if);
} else {
commit('alert/UPDATE_USE_TIME_WINDOW', false);
}
commit('alert/UPDATE_JIRA_PROJECT', config.jira_project);
commit('alert/UPDATE_JIRA_ISSUE_TYPE', config.jira_issuetype);
commit('alert/UPDATE_JIRA_COMPONENTS', config.jira_components);
@@ -865,6 +873,19 @@ export default {
return config;
},

timeWindow(state) {
let config = {};

if (state.alert.useTimeWindow) {
config.start_time = state.alert.timeWindowStartTime;
config.end_time = state.alert.timeWindowEndTime;
config.drop_if = state.alert.timeWindowDropIf;
config.match_enhancements = ['elastalert_modules.hour_range_enhancement.HourRangeEnhancement'];
}

return config;
},

jira(state) {
let config = {};

@@ -1001,7 +1022,14 @@ export default {
config.realert = state.alert.realert;
}

config = { ...config, ...getters.aggregation };
const existingMatchEnhancements = config.match_enhancements ?? [];
const timeWindowMatchEnhancements = getters.timeWindow.match_enhancements ?? [];
config = {
...config,
...getters.aggregation,
...getters.timeWindow,
match_enhancements: [...existingMatchEnhancements, ...timeWindowMatchEnhancements]
};

if (state.alert.alert.includes('post')) {
config = { ...config, ...getters.http };