diff --git a/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts b/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts index 8e659e73f9d7..bfc6e4e480c7 100644 --- a/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts +++ b/src/plugins/discover/public/application/components/chart/utils/create_histogram_configs.ts @@ -25,5 +25,13 @@ export function createHistogramConfigs( }, }, ]; - return data.search.aggs.createAggConfigs(indexPattern, visStateAggs); + + // If index pattern is created before the index, this function will fail since the required fields for the histogram agg will be missing. + try { + return data.search.aggs.createAggConfigs(indexPattern, visStateAggs); + } catch (error) { + // Just display the error to the user but continue to render the rest of the page + data.search.showError(error as Error); + return; + } }