Explore/Loki: Fix handling of legacy log row context request (#21767)

Closes #21695
This commit is contained in:
kay delaney 2020-01-27 15:45:01 +00:00 committed by GitHub
parent 00fa30f243
commit 7569a8608a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -491,22 +491,26 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
switchMap((res: { data: LokiStreamResponse; status: number }) => switchMap((res: { data: LokiStreamResponse; status: number }) =>
iif( iif(
() => res.status === 404, () => res.status === 404,
this._request(LEGACY_QUERY_ENDPOINT, target).pipe( defer(() =>
catchError((err: any) => { this._request(LEGACY_QUERY_ENDPOINT, target).pipe(
const error: DataQueryError = { catchError((err: any) => {
message: 'Error during context query. Please check JS console logs.', const error: DataQueryError = {
status: err.status, message: 'Error during context query. Please check JS console logs.',
statusText: err.statusText, status: err.status,
}; statusText: err.statusText,
throw error; };
}), throw error;
map((res: { data: LokiLegacyStreamResponse }) => ({ }),
data: res.data ? res.data.streams.map(stream => legacyLogStreamToDataFrame(stream, reverse)) : [], map((res: { data: LokiLegacyStreamResponse }) => ({
})) data: res.data ? res.data.streams.map(stream => legacyLogStreamToDataFrame(stream, reverse)) : [],
}))
)
), ),
of({ defer(() =>
data: res.data ? res.data.data.result.map(stream => lokiStreamResultToDataFrame(stream, reverse)) : [], of({
}) data: res.data ? res.data.data.result.map(stream => lokiStreamResultToDataFrame(stream, reverse)) : [],
})
)
) )
) )
) )