Skip to content

Commit

Permalink
scan_entire_timeframe support
Browse files Browse the repository at this point in the history
  • Loading branch information
nsano-rururu committed Aug 4, 2021
1 parent 229523c commit f521f8c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/components/config/ConfigScanEntireTimeframe.vue
@@ -0,0 +1,48 @@
<template>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="scan entire timeframe">
<el-switch
id="scanEntireTimeframe"
v-model="scanEntireTimeframe"
:disabled="viewOnly"
@change="changeScanEntireTimeframe" />
<label>
If true, when ElastAlert 2 starts, it will always start querying at the current time minus the timeframe.
timeframe must exist in the rule.
</label>
</el-form-item>
</el-col>
</el-row>
</template>

<script>
export default {
props: ['viewOnly'],
computed: {
scanEntireTimeframe: {
get() {
return this.$store.state.config.alert.scanEntireTimeframe;
},
set(value) {
this.$store.commit('config/alert/UPDATE_SCAN_ENTIRE_TIMEFRAME', value);
}
}
},
mounted() {
this.scanEntireTimeframe = this.$store.state.config.alert.scanEntireTimeframe;
},
methods: {
changeScanEntireTimeframe(val) {
if (val) {
this.scanEntireTimeframe = true;
} else {
this.scanEntireTimeframe = false;
}
}
}
};
</script>
6 changes: 6 additions & 0 deletions src/components/config/alert/ConfigAlert.vue
Expand Up @@ -73,6 +73,12 @@
</el-col>
</el-row>

<el-row class="m-s-sm">
<el-col :span="24">
<ConfigScanEntireTimeframe ref="scanEntireTimeframe" :view-only="viewOnly" />
</el-col>
</el-row>

<el-row class="m-s-sm">
<el-col :span="24">
<ConfigOwner ref="configOwner" :view-only="viewOnly" />
Expand Down
2 changes: 2 additions & 0 deletions src/registration.js
Expand Up @@ -21,6 +21,7 @@ import ConfigPriority from '@/components/config/ConfigPriority.vue';
import ConfigDescription from '@/components/config/ConfigDescription.vue';
import ConfigSettings from '@/components/config/ConfigSettings.vue';
import ConfigCondition from '@/components/config/ConfigCondition.vue';
import ConfigScanEntireTimeframe from '@/components/config/ConfigScanEntireTimeframe.vue';

Vue.component('Bulb', Bulb);
Vue.component('DateTime', DateTime);
Expand All @@ -34,6 +35,7 @@ Vue.component('ConfigOwner', ConfigOwner);
Vue.component('ConfigPriority', ConfigPriority);
Vue.component('ConfigDescription', ConfigDescription);
Vue.component('ConfigCondition', ConfigCondition);
Vue.component('ConfigScanEntireTimeframe', ConfigScanEntireTimeframe);
Vue.component('DefinitionTable', DefinitionTable);
Vue.component('ElastalertTimePicker', ElastalertTimePicker);
Vue.component('ESChart', ESChart);
Expand Down
8 changes: 8 additions & 0 deletions src/store/config/alert.js
Expand Up @@ -139,6 +139,9 @@ function initialState() {
useOwner: false,
configOwner: '',

/* scanEntireTimeframe */
scanEntireTimeframe: false,

/* Jira */
jiraProject: '',
jiraIssueType: '',
Expand Down Expand Up @@ -1217,6 +1220,11 @@ export default {
state.kibanaDiscoverColumns[index] = entry;
},

/* scan_entire_timeframe */
UPDATE_SCAN_ENTIRE_TIMEFRAME(state, scanEntireTimeframe) {
state.scanEntireTimeframe = scanEntireTimeframe;
},

UPDATE_REALERT(state, realert) {
state.realert = realert;
},
Expand Down
16 changes: 16 additions & 0 deletions src/store/config/index.js
Expand Up @@ -204,6 +204,9 @@ export default {
commit('alert/UPDATE_KIBANA_DISCOVER_FROM_TIMEDELTA', config.kibana_discover_from_timedelta);
commit('alert/UPDATE_KIBANA_DISCOVER_TO_TIMEDELTA', config.kibana_discover_to_timedelta);

/* scan_entire_timeframe */
commit('alert/UPDATE_SCAN_ENTIRE_TIMEFRAME', config.scan_entire_timeframe);

/* Description */
commit('alert/UPDATE_DESCRIPTION', config.description);

Expand Down Expand Up @@ -1723,6 +1726,17 @@ export default {
return config;
},

// scan_entire_timeframe
scanEntireTimeframe(state) {
let config = {};

if (state.alert.scanEntireTimeframe) {
config.scan_entire_timeframe = state.alert.scanEntireTimeframe;
}

return config;
},

// Priority
priority(state) {
let config = {};
Expand Down Expand Up @@ -2396,6 +2410,8 @@ export default {

config = { ...config, ...getters.owner };

config = { ...config, ...getters.scanEntireTimeframe };

// Sort the keys in the object so it appears alphabetically in the UI
let conf = {};

Expand Down

0 comments on commit f521f8c

Please sign in to comment.