From 59d3e7d29338d960c9fa5c9db82364d44a6cb6b7 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Thu, 25 Mar 2021 15:57:08 +0300 Subject: [PATCH] If I create a viz with the string mode and a wildcard e.g. kibana_sample*, the index patterns are not communicated correctly to the dashboard. --- .../vis_type_timeseries/public/metrics_type.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/vis_type_timeseries/public/metrics_type.ts b/src/plugins/vis_type_timeseries/public/metrics_type.ts index a89217409c1ff07..789b360d375a7d1 100644 --- a/src/plugins/vis_type_timeseries/public/metrics_type.ts +++ b/src/plugins/vis_type_timeseries/public/metrics_type.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { TSVB_EDITOR_NAME } from './application'; import { PANEL_TYPES } from '../common/panel_types'; -import { fetchIndexPattern } from '../common/index_patterns_utils'; +import { isStringTypeIndexPattern } from '../common/index_patterns_utils'; import { toExpressionAst } from './to_ast'; import { VIS_EVENT_TO_TRIGGER, VisGroups, VisParams } from '../../visualizations/public'; import { getDataStart } from './services'; @@ -79,8 +79,18 @@ export const metricsVisDefinition = { inspectorAdapters: {}, getUsedIndexPattern: async (params: VisParams) => { const { indexPatterns } = getDataStart(); - const { indexPattern } = await fetchIndexPattern(params.index_pattern, indexPatterns); + const indexPatternValue = params.index_pattern; - return indexPattern ? [indexPattern] : []; + if (indexPatternValue) { + if (isStringTypeIndexPattern(indexPatternValue)) { + return await indexPatterns.find(indexPatternValue); + } + + if (indexPatternValue.id) { + return [await indexPatterns.get(indexPatternValue.id)]; + } + } + + return [await indexPatterns.getDefault()]; }, };