Skip to content

Commit

Permalink
fix: fix error timefield and add filter for multi same name index pat…
Browse files Browse the repository at this point in the history
…tern (#345)

* fix: fix error timefield and add filter for multi same name index pattern belong to current data source

Signed-off-by: tygao <tygao@amazon.com>

* doc: add changelog

Signed-off-by: tygao <tygao@amazon.com>

---------

Signed-off-by: tygao <tygao@amazon.com>
(cherry picked from commit 2f06c5d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] committed Oct 12, 2024
1 parent 0218e09 commit d63c893
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/utils/alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export const createIndexPatterns = async (
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);
let result = await dataStart.indexPatterns.find(patternName);
if (dataSourceId) {
// Filter same name index patterns but belonged to current data source
result = result.filter((item) => item?.dataSourceRef?.id === dataSourceId);
}
if (result && result[0]) {
pattern = result[0];
}
Expand Down Expand Up @@ -101,7 +105,7 @@ export const buildUrlQuery = async (
dataset: {
type: 'INDEX_PATTERN',
id: indexPattern.id,
timeFiledName: indexPattern.timeFieldName,
timeFieldName: indexPattern.timeFieldName,
title: indexPatternTitle,
},
language: 'kuery',
Expand Down

0 comments on commit d63c893

Please sign in to comment.