[Logs UI] Avoid CCS-incompatible index name resolution (#70179)
This fixes #70048 by avoiding a CCS-incompatible ES API call when determining the existence of log indices.
This commit is contained in:
parent
8a6a55097d
commit
e70bc81998
|
@ -42,7 +42,7 @@ export type LogIndexField = rt.TypeOf<typeof logIndexFieldRT>;
|
||||||
|
|
||||||
const logSourceStatusRT = rt.strict({
|
const logSourceStatusRT = rt.strict({
|
||||||
logIndexFields: rt.array(logIndexFieldRT),
|
logIndexFields: rt.array(logIndexFieldRT),
|
||||||
logIndexNames: rt.array(rt.string),
|
logIndicesExist: rt.boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type LogSourceStatus = rt.TypeOf<typeof logSourceStatusRT>;
|
export type LogSourceStatus = rt.TypeOf<typeof logSourceStatusRT>;
|
||||||
|
|
|
@ -78,11 +78,6 @@ export const useLogSource = ({
|
||||||
[sourceId, fetch]
|
[sourceId, fetch]
|
||||||
);
|
);
|
||||||
|
|
||||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
||||||
const logIndicesExist = useMemo(() => (sourceStatus?.logIndexNames?.length ?? 0) > 0, [
|
|
||||||
sourceStatus,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const derivedIndexPattern = useMemo(
|
const derivedIndexPattern = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
fields: sourceStatus?.logIndexFields ?? [],
|
fields: sourceStatus?.logIndexFields ?? [],
|
||||||
|
@ -160,7 +155,6 @@ export const useLogSource = ({
|
||||||
loadSourceFailureMessage,
|
loadSourceFailureMessage,
|
||||||
loadSourceConfiguration,
|
loadSourceConfiguration,
|
||||||
loadSourceStatus,
|
loadSourceStatus,
|
||||||
logIndicesExist,
|
|
||||||
sourceConfiguration,
|
sourceConfiguration,
|
||||||
sourceId,
|
sourceId,
|
||||||
sourceStatus,
|
sourceStatus,
|
||||||
|
|
|
@ -18,14 +18,14 @@ export const StreamPageContent: React.FunctionComponent = () => {
|
||||||
isUninitialized,
|
isUninitialized,
|
||||||
loadSource,
|
loadSource,
|
||||||
loadSourceFailureMessage,
|
loadSourceFailureMessage,
|
||||||
logIndicesExist,
|
sourceStatus,
|
||||||
} = useLogSourceContext();
|
} = useLogSourceContext();
|
||||||
|
|
||||||
if (isLoading || isUninitialized) {
|
if (isLoading || isUninitialized) {
|
||||||
return <SourceLoadingPage />;
|
return <SourceLoadingPage />;
|
||||||
} else if (hasFailedLoadingSource) {
|
} else if (hasFailedLoadingSource) {
|
||||||
return <SourceErrorPage errorMessage={loadSourceFailureMessage ?? ''} retry={loadSource} />;
|
return <SourceErrorPage errorMessage={loadSourceFailureMessage ?? ''} retry={loadSource} />;
|
||||||
} else if (logIndicesExist) {
|
} else if (sourceStatus?.logIndicesExist) {
|
||||||
return <LogsPageLogsContent />;
|
return <LogsPageLogsContent />;
|
||||||
} else {
|
} else {
|
||||||
return <LogsPageNoIndicesContent />;
|
return <LogsPageNoIndicesContent />;
|
||||||
|
|
|
@ -104,10 +104,10 @@ const LogHighlightsStateProvider: React.FC = ({ children }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
|
export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
|
||||||
const { logIndicesExist } = useLogSourceContext();
|
const { sourceStatus } = useLogSourceContext();
|
||||||
|
|
||||||
// The providers assume the source is loaded, so short-circuit them otherwise
|
// The providers assume the source is loaded, so short-circuit them otherwise
|
||||||
if (!logIndicesExist) {
|
if (!sourceStatus?.logIndicesExist) {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,16 @@ export const initLogSourceStatusRoutes = ({
|
||||||
const { sourceId } = request.params;
|
const { sourceId } = request.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const logIndexNames = await sourceStatus.getLogIndexNames(requestContext, sourceId);
|
const logIndicesExist = await sourceStatus.hasLogIndices(requestContext, sourceId);
|
||||||
const logIndexFields =
|
const logIndexFields = logIndicesExist
|
||||||
logIndexNames.length > 0
|
? await fields.getFields(requestContext, sourceId, InfraIndexType.LOGS)
|
||||||
? await fields.getFields(requestContext, sourceId, InfraIndexType.LOGS)
|
: [];
|
||||||
: [];
|
|
||||||
|
|
||||||
return response.ok({
|
return response.ok({
|
||||||
body: getLogSourceStatusSuccessResponsePayloadRT.encode({
|
body: getLogSourceStatusSuccessResponsePayloadRT.encode({
|
||||||
data: {
|
data: {
|
||||||
|
logIndicesExist,
|
||||||
logIndexFields,
|
logIndexFields,
|
||||||
logIndexNames,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue