diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffa7fc..77dc870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - different query start times with multiple queries due to mutating of grafana start time +### Added + +- Default Percentile Value when percentile metric is selected + ## 1.1.1 ### Added diff --git a/src/components/QueryEditor.tsx b/src/components/QueryEditor.tsx index b74ae5e..ce3c8c5 100644 --- a/src/components/QueryEditor.tsx +++ b/src/components/QueryEditor.tsx @@ -69,7 +69,17 @@ export function QueryEditor(props: Props) { }; const handleAggregationChange = (item: SelectableValue) => { - props.onChange({ ...query, metric: item.value }); + // set a default value when percentile is selected and delete percentileValue when percentile is deselected + // to not pollute the dashboard.json file + let percentile = undefined; + if (item.value === 'percentile' && percentileValue == null) { + setPercentileValue(95); + percentile = 95; + } else { + setPercentileValue(undefined); + } + + props.onChange({ ...query, metric: item.value, percentileValue: percentile }); props.onRunQuery(); };