-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from quickwit-oss/ddelemeny/configurable-edit…
…or-defaults Make log limits configurable
- Loading branch information
Showing
10 changed files
with
139 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
MetricAggregation, | ||
MetricAggregationType, | ||
Logs as SchemaLogs, | ||
} from '@/dataquery.gen'; | ||
import { Logs, LogsSortDirection } from "@/types"; | ||
|
||
export type QuickwitMetricAggregationType = Extract<'count' | 'avg' | 'sum' | 'min' | 'max' | 'percentiles' | 'raw_data' | 'logs', MetricAggregationType > | ||
|
||
export type MetricsDefaultSettings = Partial<{ | ||
[T in QuickwitMetricAggregationType]: Omit<Extract<Exclude<MetricAggregation,SchemaLogs>|Logs, { type: T }>, 'id' | 'type'>; | ||
}>; | ||
|
||
|
||
export const defaultMetricAggregationConfig: MetricsDefaultSettings = { | ||
percentiles: { | ||
settings: { | ||
percents: ['25', '50', '75', '95', '99'], | ||
}, | ||
}, | ||
raw_data: { | ||
settings: { | ||
size: '100', | ||
}, | ||
}, | ||
logs: { | ||
settings: { | ||
limit: '100', | ||
sortDirection:'desc' as LogsSortDirection | ||
}, | ||
}, | ||
}; | ||
|
||
export const defaultConfig = { | ||
metricAggregation: defaultMetricAggregationConfig | ||
}; | ||
|
||
export type DefaultsConfig = typeof defaultConfig | ||
|
||
export type DefaultsConfigOverrides = {[key: string]: any}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
import { defaultConfig , DefaultsConfigOverrides } from "./conf"; | ||
import _ from "lodash"; | ||
|
||
export const initialState = defaultConfig | ||
|
||
const defaultsSlice = createSlice({ | ||
name: "defaults", | ||
initialState: defaultConfig, | ||
reducers: { | ||
initDefaults(_s, action: PayloadAction<DefaultsConfigOverrides | undefined>) { | ||
// Initialize from default state, dont keep the old one | ||
let newState = _.cloneDeep(defaultConfig); | ||
// override values with payload | ||
if (action.payload) { | ||
const overrides = action.payload; | ||
for (const key in overrides) { | ||
// XXX : this is very not type-safe. Can do better ? | ||
const value = overrides[key]; | ||
newState = _.set(newState, key, value); | ||
} | ||
} | ||
return newState | ||
} | ||
} | ||
}) | ||
|
||
const {actions, reducer} = defaultsSlice | ||
export const { | ||
initDefaults, | ||
} = actions | ||
|
||
export default reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import defaultsReducer from "./defaults" | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
defaults: defaultsReducer, | ||
} | ||
}) | ||
|
||
// Infer the `RootState` and `AppDispatch` types from the store itself | ||
export type RootState = ReturnType<typeof store.getState> | ||
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState} | ||
export type AppDispatch = typeof store.dispatch |