mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Synthetics] Fix index not existence error (#134018)
This commit is contained in:
parent
b0ff0c1c53
commit
ef9ab9acdd
2 changed files with 26 additions and 14 deletions
|
@ -89,7 +89,7 @@ export function createUptimeESClient({
|
|||
esError,
|
||||
esRequestParams: esParams,
|
||||
esRequestStatus,
|
||||
esResponse: res.body,
|
||||
esResponse: res?.body,
|
||||
kibanaRequest: request!,
|
||||
operationName: operationName ?? '',
|
||||
startTime: startTimeNow,
|
||||
|
|
|
@ -11,18 +11,30 @@ import { StatesIndexStatus } from '../../../../common/runtime_types';
|
|||
export const getIndexStatus: UMElasticsearchQueryFn<{}, StatesIndexStatus> = async ({
|
||||
uptimeEsClient,
|
||||
}) => {
|
||||
const {
|
||||
indices,
|
||||
result: {
|
||||
body: {
|
||||
_shards: { total },
|
||||
count,
|
||||
try {
|
||||
const {
|
||||
indices,
|
||||
result: {
|
||||
body: {
|
||||
_shards: { total },
|
||||
count,
|
||||
},
|
||||
},
|
||||
},
|
||||
} = await uptimeEsClient.count({ terminate_after: 1 });
|
||||
return {
|
||||
indices,
|
||||
indexExists: total > 0,
|
||||
docCount: count,
|
||||
};
|
||||
} = await uptimeEsClient.count({ terminate_after: 1 });
|
||||
return {
|
||||
indices,
|
||||
indexExists: total > 0,
|
||||
docCount: count,
|
||||
};
|
||||
} catch (e) {
|
||||
if (e.meta.statusCode === 404) {
|
||||
// we don't throw an error for index not found
|
||||
return {
|
||||
indices: '',
|
||||
indexExists: false,
|
||||
docCount: 0,
|
||||
};
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue