Fix data stream API when event.ingested is null (#135817)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Kyle Pollich 2022-07-06 12:06:46 -04:00 committed by GitHub
parent 5a266b7c59
commit f15355a36f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,10 +24,7 @@ export async function getDataStreamsQueryMetadata({
esClient.search({
size: 1,
index: dataStreamName,
sort: {
// @ts-expect-error Type '{ 'event.ingested': string; }' is not assignable to type 'string | string[] | undefined'.
'event.ingested': 'desc',
},
sort: 'event.ingested:desc',
_source: false,
fields: ['event.ingested'],
}),
@ -55,9 +52,10 @@ export async function getDataStreamsQueryMetadata({
}),
]);
const maxIngested = new Date(
maxEventIngestedResponse.hits.hits[0]?.fields!['event.ingested']
).getTime();
const maxIngested =
maxEventIngestedResponse.hits.hits[0]?.fields !== undefined
? new Date(maxEventIngestedResponse.hits.hits[0].fields['event.ingested']).getTime()
: undefined;
const namespace = namespaceResponse.terms[0] ?? '';
const dataset = datasetResponse.terms[0] ?? '';