Skip to content

Commit

Permalink
[7.x] [Metrics UI] Fix alert previews of ungrouped alerts (#73735) (#…
Browse files Browse the repository at this point in the history
…73911)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
Zacqary and elasticmachine committed Jul 31, 2020
1 parent 06b1d83 commit 9ca600e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ export const Expressions: React.FC<Props> = (props) => {
[onFilterChange]
);

const groupByPreviewDisplayName = useMemo(() => {
if (Array.isArray(alertParams.groupBy)) return alertParams.groupBy.join(', ');
return alertParams.groupBy;
}, [alertParams.groupBy]);

return (
<>
<EuiSpacer size={'m'} />
Expand Down Expand Up @@ -400,7 +405,7 @@ export const Expressions: React.FC<Props> = (props) => {
showNoDataResults={alertParams.alertOnNoData}
validate={validateMetricThreshold}
fetch={alertsContext.http.fetch}
groupByDisplayName={alertParams.groupBy}
groupByDisplayName={groupByPreviewDisplayName}
/>
<EuiSpacer size={'m'} />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface Props {
derivedIndexPattern: IIndexPattern;
source: InfraSource | null;
filterQuery?: string;
groupBy?: string;
groupBy?: string | string[];
}

const tooltipProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useMetricsExplorerChartData = (
derivedIndexPattern: IIndexPattern,
source: InfraSource | null,
filterQuery?: string,
groupBy?: string
groupBy?: string | string[]
) => {
const { timeSize, timeUnit } = expression || { timeSize: 1, timeUnit: 'm' };
const options: MetricsExplorerOptions = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface ExpressionChartData {

export interface AlertParams {
criteria: MetricExpression[];
groupBy?: string;
groupBy?: string[];
filterQuery?: string;
sourceId?: string;
filterQueryText?: string;
Expand Down

0 comments on commit 9ca600e

Please sign in to comment.