Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-obs-hook-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored May 11, 2023
2 parents 3cb2dcb + cec3ee9 commit 52854ca
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { TrainedModelState } from '../../../../../../../common/types/pipelines';
import { GetDocumentsApiLogic } from '../../../../api/documents/get_document_logic';
import { MappingsApiLogic } from '../../../../api/mappings/mappings_logic';
import { MLModelsApiLogic } from '../../../../api/ml_models/ml_models_logic';
import { StartTextExpansionModelApiLogic } from '../../../../api/ml_models/text_expansion/start_text_expansion_model_api_logic';
import { AttachMlInferencePipelineApiLogic } from '../../../../api/pipelines/attach_ml_inference_pipeline';
import { CreateMlInferencePipelineApiLogic } from '../../../../api/pipelines/create_ml_inference_pipeline';
import { FetchMlInferencePipelineProcessorsApiLogic } from '../../../../api/pipelines/fetch_ml_inference_pipeline_processors';
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('MlInferenceLogic', () => {
FetchMlInferencePipelinesApiLogic
);
const { mount: mountGetDocumentsApiLogic } = new LogicMounter(GetDocumentsApiLogic);
const { mount: mountStartTextExpansionModel } = new LogicMounter(StartTextExpansionModelApiLogic);

beforeEach(() => {
jest.clearAllMocks();
Expand All @@ -97,6 +99,7 @@ describe('MlInferenceLogic', () => {
mountCreateMlInferencePipelineApiLogic();
mountAttachMlInferencePipelineApiLogic();
mountGetDocumentsApiLogic();
mountStartTextExpansionModel();
mount();
});

Expand Down Expand Up @@ -628,5 +631,16 @@ describe('MlInferenceLogic', () => {
});
});
});
describe('startTextExpansionModelSuccess', () => {
it('fetches ml models', () => {
jest.spyOn(MLInferenceLogic.actions, 'makeMLModelsRequest');
StartTextExpansionModelApiLogic.actions.apiSuccess({
deploymentState: 'started',
modelId: 'foo',
});

expect(MLInferenceLogic.actions.makeMLModelsRequest).toHaveBeenCalledWith(undefined);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
TrainedModelsApiLogicActions,
TrainedModelsApiLogic,
} from '../../../../api/ml_models/ml_trained_models_logic';
import {
StartTextExpansionModelApiLogic,
StartTextExpansionModelApiLogicActions,
} from '../../../../api/ml_models/text_expansion/start_text_expansion_model_api_logic';
import {
AttachMlInferencePipelineApiLogic,
AttachMlInferencePipelineApiLogicArgs,
Expand Down Expand Up @@ -156,6 +160,7 @@ interface MLInferenceProcessorsActions {
setInferencePipelineConfiguration: (configuration: InferencePipelineConfiguration) => {
configuration: InferencePipelineConfiguration;
};
startTextExpansionModelSuccess: StartTextExpansionModelApiLogicActions['apiSuccess'];
}

export interface AddInferencePipelineModal {
Expand Down Expand Up @@ -230,6 +235,8 @@ export const MLInferenceLogic = kea<
],
PipelinesLogic,
['closeAddMlInferencePipelineModal as closeAddMlInferencePipelineModal'],
StartTextExpansionModelApiLogic,
['apiSuccess as startTextExpansionModelSuccess'],
],
values: [
CachedFetchIndexApiLogic,
Expand Down Expand Up @@ -316,6 +323,10 @@ export const MLInferenceLogic = kea<
});
}
},
startTextExpansionModelSuccess: () => {
// Refresh ML models list when the text expansion model is started
actions.makeMLModelsRequest(undefined);
},
}),
path: ['enterprise_search', 'content', 'pipelines_add_ml_inference_pipeline'],
reducers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useQuery,
useQueryClient,
} from '@tanstack/react-query';
import { i18n } from '@kbn/i18n';
import { FindSLOResponse } from '@kbn/slo-schema';

import { useKibana } from '../../utils/kibana_react';
Expand Down Expand Up @@ -47,10 +48,15 @@ export function useFetchSloList({
indicatorTypes = [],
shouldRefetch,
}: SLOListParams | undefined = {}): UseFetchSloListResponse {
const { http } = useKibana().services;
const {
http,
notifications: { toasts },
} = useKibana().services;
const queryClient = useQueryClient();

const [stateRefetchInterval, setStateRefetchInterval] = useState(SHORT_REFETCH_INTERVAL);
const [stateRefetchInterval, setStateRefetchInterval] = useState<number | undefined>(
SHORT_REFETCH_INTERVAL
);

const { isInitialLoading, isLoading, isError, isSuccess, isRefetching, data, refetch } = useQuery(
{
Expand All @@ -72,13 +78,19 @@ export function useFetchSloList({

return response;
} catch (error) {
// ignore error
throw error;
}
},
keepPreviousData: true,
refetchOnWindowFocus: false,
refetchInterval: shouldRefetch ? stateRefetchInterval : undefined,
staleTime: 1000,
retry: (failureCount, error) => {
if (String(error) === 'Error: Forbidden') {
return false;
}
return failureCount < 4;
},
onSuccess: ({ results }: FindSLOResponse) => {
if (!shouldRefetch) {
return;
Expand All @@ -102,6 +114,13 @@ export function useFetchSloList({
exact: false,
});
},
onError: (error: Error) => {
toasts.addError(error, {
title: i18n.translate('xpack.observability.slo.list.errorNotification', {
defaultMessage: 'Something went wrong while fetching SLOs',
}),
});
},
}
);

Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/observability/public/pages/slos/slos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function SlosPage() {
const { hasWriteCapabilities } = useCapabilities();
const { hasAtLeast } = useLicense();

const { isInitialLoading, isLoading, sloList } = useFetchSloList();
const { isInitialLoading, isLoading, isError, sloList } = useFetchSloList();

const { total } = sloList || {};

Expand All @@ -46,6 +46,12 @@ export function SlosPage() {
},
]);

useEffect(() => {
if ((!isLoading && total === 0) || hasAtLeast('platinum') === false || isError) {
navigateToUrl(basePath.prepend(paths.observability.slosWelcome));
}
}, [basePath, hasAtLeast, isError, isLoading, navigateToUrl, total]);

const handleClickCreateSlo = () => {
navigateToUrl(basePath.prepend(paths.observability.sloCreate));
};
Expand All @@ -54,12 +60,6 @@ export function SlosPage() {
setIsAutoRefreshing(!isAutoRefreshing);
};

useEffect(() => {
if ((!isLoading && total === 0) || hasAtLeast('platinum') === false) {
navigateToUrl(basePath.prepend(paths.observability.slosWelcome));
}
}, [basePath, hasAtLeast, isLoading, navigateToUrl, total]);

if (isInitialLoading) {
return null;
}
Expand Down
32 changes: 22 additions & 10 deletions x-pack/plugins/profiling/public/components/no_data_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function NoDataPage({ subTitle }: { subTitle: string }) {

const secretToken = data?.variables.secretToken;
const collectionAgentHostPort = data?.variables.apmServerUrl.replace('https://', '');
const hostAgentVersion = 'v3';

const tabs = [
{
Expand Down Expand Up @@ -66,7 +67,7 @@ export function NoDataPage({ subTitle }: { subTitle: string }) {
{`helm install --create-namespace -n=universal-profiling universal-profiling-agent \\
--set "projectID=1,secretToken=${secretToken}" \\
--set "collectionAgentHostPort=${collectionAgentHostPort}" \\
--set "image.baseUrl=docker.elastic.co,image.repository=observability,image.name=profiling-agent" \\
--set "version=${hostAgentVersion}" \\
optimyze/pf-host-agent`}
</EuiCodeBlock>
),
Expand Down Expand Up @@ -104,7 +105,7 @@ optimyze/pf-host-agent`}
<EuiCodeBlock paddingSize="s" isCopyable>
{`docker run --name host-agent --privileged --pid=host -v /etc/machine-id:/etc/machine-id:ro \\
-v /var/run/docker.sock:/var/run/docker.sock -v /sys/kernel/debug:/sys/kernel/debug:ro \\
docker.elastic.co/observability/profiling-agent:stable /root/pf-host-agent \\
docker.elastic.co/observability/profiling-agent:${hostAgentVersion} /root/pf-host-agent \\
-project-id=1 -secret-token=${secretToken} \\
-collection-agent=${collectionAgentHostPort}`}
</EuiCodeBlock>
Expand All @@ -124,8 +125,7 @@ docker.elastic.co/observability/profiling-agent:stable /root/pf-host-agent \\
}),
content: (
<EuiCodeBlock paddingSize="s" isCopyable>
wget -O pf-host-agent.tgz &quot;https://ela.st/pf-host-agent-amd64&quot; && tar xzf
pf-host-agent.tgz
{`wget -O pf-host-agent.tgz "https://ela.st/pf-host-agent-amd64-${hostAgentVersion}" && tar xzf pf-host-agent.tgz`}
</EuiCodeBlock>
),
},
Expand Down Expand Up @@ -163,8 +163,11 @@ docker.elastic.co/observability/profiling-agent:stable /root/pf-host-agent \\
'Open the URL below and download the right DEB package for your CPU architecture:',
}),
content: (
<EuiLink target="_blank" href={`https://ela.st/pf-host-agent-linux`}>
https://ela.st/pf-host-agent-linux
<EuiLink
target="_blank"
href={`https://ela.st/pf-host-agent-linux-${hostAgentVersion}`}
>
{`https://ela.st/pf-host-agent-linux-${hostAgentVersion}`}
</EuiLink>
),
},
Expand Down Expand Up @@ -213,8 +216,11 @@ docker.elastic.co/observability/profiling-agent:stable /root/pf-host-agent \\
'Open the URL below and download the right RPM package for your CPU architecture:',
}),
content: (
<EuiLink target="_blank" href={`https://ela.st/pf-host-agent-linux`}>
https://ela.st/pf-host-agent-linux
<EuiLink
target="_blank"
href={`https://ela.st/pf-host-agent-linux-${hostAgentVersion}`}
>
{`https://ela.st/pf-host-agent-linux-${hostAgentVersion}`}
</EuiLink>
),
},
Expand Down Expand Up @@ -284,11 +290,17 @@ docker.elastic.co/observability/profiling-agent:stable /root/pf-host-agent \\
},
{
title: i18n.translate('xpack.profiling.tabs.symbols.step3', {
defaultMessage: 'Run:',
defaultMessage:
'Fetch the symbols endpoint from the Cloud console, navigating in the Integrations Server section',
}),
},
{
title: i18n.translate('xpack.profiling.tabs.symbols.step4', {
defaultMessage: 'Run the following command, replacing the placeholders between <>:',
}),
content: (
<EuiCodeBlock paddingSize="s" isCopyable>
{`./symbtool push-symbols executable --url <symb service IP> --api-key {} --help`}
{`./symbtool push-symbols executable --url <symbols endpoint> --api-key <api key> --help`}
</EuiCodeBlock>
),
},
Expand Down

0 comments on commit 52854ca

Please sign in to comment.