Skip to content

Commit

Permalink
Handle getting Processing and Indexing Failures stream name for non e…
Browse files Browse the repository at this point in the history
…nterprise version (#18143)
  • Loading branch information
maxiadlovskii authored Feb 2, 2024
1 parent 18ac529 commit 22a6108
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ const fetchStream = (streamId: string) => {
return fetch('GET', qualifyUrl(url));
};

const useStream = (streamId: string): {
const useStream = (streamId: string, { enabled } = { enabled: true }): {
data: Stream
refetch: () => void,
isFetching: boolean,
isError,
} => {
const { data, refetch, isFetching } = useQuery(
const { data, refetch, isFetching, isError } = useQuery(
['streams', streamId],
() => fetchStream(streamId),
{
Expand All @@ -42,13 +43,15 @@ const useStream = (streamId: string): {
'Could not load Stream');
},
keepPreviousData: true,
enabled,
},
);

return ({
data,
refetch,
isFetching,
isError,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { getPathnameWithoutId } from 'util/URLUtils';
import useLocation from 'routing/useLocation';
import FieldSelect from 'views/logic/fieldactions/ChangeFieldType/FieldSelect';
import useFieldTypesForMappings from 'views/logic/fieldactions/ChangeFieldType/hooks/useFieldTypesForMappings';
import { Link } from 'components/common/router';
import Routes from 'routing/Routes';

const StyledSelect = styled(Select)`
width: 400px;
Expand Down Expand Up @@ -64,6 +66,18 @@ type Props = {
}
}

const FailureStreamLink = () => {
const { data: failureStream, isFetching: isFetchingFailureStream, isError: isErrorFailureStream } = useStream(failureStreamId);
if (isFetchingFailureStream) return <Spinner />;

return (
<span>
<StreamLink stream={isErrorFailureStream ? { id: failureStreamId, title: 'Processing and Indexing Failures' } : failureStream} />
<i> (<Link to={Routes.SYSTEM.ENTERPRISE}>Enterprise Plugin</Link> required)</i>
</span>
);
};

const ChangeFieldTypeModal = ({
show,
onSubmitCallback,
Expand All @@ -83,7 +97,6 @@ const ChangeFieldTypeModal = ({
value,
label,
})), [fieldTypes]);
const { data: failureStream, isFetching: failureStreamLoading } = useStream(failureStreamId);

const [indexSetSelection, setIndexSetSelection] = useState<Array<string>>();

Expand Down Expand Up @@ -149,7 +162,7 @@ const ChangeFieldTypeModal = ({
Changing the type of the field <b>{fieldName}</b> can have a significant impact on the ingestion of future log messages.
If you declare a field to have a type which is incompatible with the logs you are ingesting, it can lead to
ingestion errors. It is recommended to enable <DocumentationLink page={DocsHelper.PAGES.INDEXER_FAILURES} displayIcon text="Failure Processing" /> and watch
the {failureStreamLoading ? <Spinner /> : <StreamLink stream={failureStream} />} stream closely afterwards.
the <FailureStreamLink /> stream closely afterwards.
</Alert>
<StyledLabel>{`Select Field Type For ${fieldName || 'Field'}`}</StyledLabel>
<Input id="field_type">
Expand Down

0 comments on commit 22a6108

Please sign in to comment.