Skip to content

Commit

Permalink
If I create a viz with the string mode and a wildcard e.g. kibana_sam…
Browse files Browse the repository at this point in the history
…ple*, the index patterns are not communicated correctly to the dashboard.
  • Loading branch information
alexwizp committed Mar 25, 2021
1 parent 9715acc commit 9d7c237
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/plugins/vis_type_timeseries/public/metrics_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,8 +79,20 @@ 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)];
}
}

const defaultIndex = await indexPatterns.getDefault();

return defaultIndex ? [defaultIndex] : [];
},
};

0 comments on commit 9d7c237

Please sign in to comment.