Skip to content

Commit

Permalink
fix: fix create index pattern duplicate cases
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Sep 29, 2024
1 parent b02b580 commit 7bfc1ef
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions public/utils/alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ export const createIndexPatterns = async (
dataSourceRef,
});
} catch (err) {
if (err instanceof DuplicateIndexPatternError) {
console.error('Create index pattern error', err.message);
// Err instanceof DuplicateIndexPatternError is not a trusted validation in some cases, so find index pattern directly.
try {
const result = await dataStart.indexPatterns.find(patternName);
if (result && result[0]) {
pattern = result[0];
}
console.error('Duplicate index pattern', err.message);
} else {
console.error('err', err.message);
} catch (e) {
console.error('Find index pattern error', err.message);
}
}
return pattern;
Expand Down

0 comments on commit 7bfc1ef

Please sign in to comment.