Skip to content

Commit

Permalink
Updates aggregation/explore to fit user settings
Browse files Browse the repository at this point in the history
User settings must be loaded before the sketch to transmit the new
parameter to POST /sketches/{id}/aggregation/explore/.
  • Loading branch information
jbaptperez committed Feb 5, 2025
1 parent 9495773 commit 91be24c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
11 changes: 9 additions & 2 deletions timesketch/api/v1/resources/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,15 @@ def post(self, sketch_id):
"Not able to run aggregation on an archived sketch.",
)

include_processing_timelines = form.include_processing_timelines.data
allowed_statuses = ["ready"]
if include_processing_timelines:
allowed_statuses.append("processing")

sketch_indices = {
t.searchindex.index_name
for t in sketch.timelines
if t.get_status.status.lower() in ["ready", "processing"]
if t.get_status.status.lower() in allowed_statuses
}

aggregation_dsl = form.aggregation_dsl.data
Expand All @@ -492,7 +497,9 @@ def post(self, sketch_id):
aggregator_parameters = {}

indices = aggregator_parameters.pop("index", sketch_indices)
indices, timeline_ids = lib_utils.get_validated_indices(indices, sketch)
indices, timeline_ids = lib_utils.get_validated_indices(
indices, sketch, form.include_processing_timelines.data
)

if not (indices or timeline_ids):
abort(HTTP_STATUS_CODE_BAD_REQUEST, "No indices to aggregate on")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ export default {
aggregator_parameters: {
field: this.eventKey,
field_query_string: this.eventValue
}
},
include_processing_timelines: !!this.settings.showProcessingTimelineEvents,
}).then((response) => {
this.stats = response.data.objects[0].field_summary.buckets[0]
this.statsReady = true
Expand All @@ -570,7 +571,8 @@ export default {
aggregator_parameters: {
field: this.eventKey,
date_interval: this.selectedDistributionInterval
}
},
include_processing_timelines: !!this.settings.showProcessingTimelineEvents,
}).then((response) => {
this.eventDistributionData = response.data.objects[0].datefield_summary.buckets[0]
this.eventDistributionReady = true
Expand Down Expand Up @@ -624,7 +626,8 @@ export default {
supported_intervals: supportedIntervals,
start_time: startTime.toISOString().slice(0, -1),
end_time: endTime.toISOString().slice(0, -1),
}
},
include_processing_timelines: !!this.settings.showProcessingTimelineEvents,
}).then((response) => {
this.data = response.data.objects[0].date_histogram.buckets[0]
this.recentHistogramSeries = [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ limitations under the License.
-->
<template>
<v-card class="mx-3" outlined>
<ts-chart-card
<ts-chart-card
v-if="aggregationId"
:chartSeries="chartSeries"
:chartSeries="chartSeries"
:chartLabels="chartLabels"
:chartTitle="chartTitle"
:chartType="chartType"
Expand Down Expand Up @@ -70,6 +70,9 @@ export default {
sketch() {
return this.$store.state.sketch
},
settings() {
return this.$store.state.settings
},
},
methods: {
loadAggregationData(savedAggregationId) {
Expand All @@ -80,7 +83,8 @@ export default {
const agg = response.data.objects[0]
this.aggregationType = agg.agg_type
this.parameters = JSON.parse(agg.parameters)

this.parameters['include_processing_timelines'] = !!this.settings.showProcessingTimelineEvents

ApiClient.runAggregator(
this.sketch.id, this.parameters
).then(
Expand Down Expand Up @@ -112,7 +116,7 @@ export default {
console.error('Error requesting aggregation parameters: ' + e)
}
)
},
},
},
watch: {
aggregationId: function (newAggregationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ export default {
}
return undefined
},
settings() {
return this.$store.state.settings
},
},
methods: {
rename() {
Expand Down Expand Up @@ -438,7 +441,8 @@ export default {
xTitle: this.selectedXTitle,
yTitle: this.selectedYTitle,
},
}
},
include_processing_timelines: !!this.settings.showProcessingTimelineEvents,
}
},
loadAggregationData() {
Expand Down
2 changes: 2 additions & 0 deletions timesketch/frontend-ng/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export default new Vuex.Store({
field: 'tag',
limit: '1000',
},
include_processing_timelines: !!state.settings.showProcessingTimelineEvents,
}
return ApiClient.runAggregator(payload.sketchId, formData)
.then((response) => {
Expand Down Expand Up @@ -292,6 +293,7 @@ export default new Vuex.Store({
field: 'data_type',
limit: '1000',
},
include_processing_timelines: !!state.settings.showProcessingTimelineEvents,
}
return ApiClient.runAggregator(sketchId, formData)
.then((response) => {
Expand Down
6 changes: 3 additions & 3 deletions timesketch/frontend-ng/src/views/Sketch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ export default {
mounted() {
this.loadingSketch = true
this.showLeftPanel = false
this.$store.dispatch('updateSketch', this.sketchId).then(() => {
this.$store.dispatch('updateUserSettings').then(() =>
this.$store.dispatch('updateSketch', this.sketchId)).then(() => {
this.$store.dispatch('updateSearchHistory', this.sketchId)
this.$store.dispatch('updateScenarioTemplates', this.sketchId)
this.$store.dispatch('updateSavedGraphs', this.sketchId)
this.$store.dispatch('updateGraphPlugins')
this.$store.dispatch('updateContextLinks')
this.$store.dispatch('updateAnalyzerList', this.sketchId)
this.$store.dispatch('updateSystemSettings')
this.$store.dispatch('updateUserSettings').then(() => {
this.$store.dispatch('updateSystemSettings').then(() => {
if (this.userSettings.showLeftPanel) {
this.toggleDrawer()
}
Expand Down
3 changes: 3 additions & 0 deletions timesketch/lib/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ class AggregationExploreForm(BaseForm):
aggregator_parameters = StringField(
"Aggregator Parameters", validators=[Optional()]
)
include_processing_timelines = BooleanField(
"Include processing timelines", validators=[Optional()], default=False
)


class AggregationLegacyForm(ExploreForm):
Expand Down

0 comments on commit 91be24c

Please sign in to comment.