diff --git a/x-pack/plugins/osquery/public/live_queries/form/index.tsx b/x-pack/plugins/osquery/public/live_queries/form/index.tsx index 287c8b25b45b1..c584de8d05409 100644 --- a/x-pack/plugins/osquery/public/live_queries/form/index.tsx +++ b/x-pack/plugins/osquery/public/live_queries/form/index.tsx @@ -12,6 +12,7 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 're import { useForm as useHookForm, FormProvider } from 'react-hook-form'; import { isEmpty, find, pickBy, isNumber } from 'lodash'; +import { QUERY_TIMEOUT } from '../../../common/constants'; import { containsDynamicQuery, replaceParamsQuery, @@ -50,6 +51,7 @@ interface DefaultLiveQueryFormFields { savedQueryId?: string | null; ecs_mapping?: ECSMapping; packId?: string; + timeout?: number; } type FormType = 'simple' | 'steps'; @@ -245,11 +247,11 @@ const LiveQueryFormComponent: React.FC = ({ setValue('agentSelection', defaultValue.agentSelection); } - if (defaultValue?.alertIds?.length) { + if (defaultValue.alertIds?.length) { setValue('alertIds', defaultValue.alertIds); } - if (defaultValue?.packId && canRunPacks) { + if (defaultValue.packId && canRunPacks) { setValue('queryType', 'pack'); if (!isPackDataFetched) return; @@ -261,10 +263,11 @@ const LiveQueryFormComponent: React.FC = ({ return; } - if (defaultValue?.query && canRunSingleQuery) { + if (defaultValue.query && canRunSingleQuery) { setValue('query', defaultValue.query); setValue('savedQueryId', defaultValue.savedQueryId); setValue('ecs_mapping', defaultValue.ecs_mapping ?? {}); + setValue('timeout', defaultValue.timeout ?? QUERY_TIMEOUT.DEFAULT); return; } diff --git a/x-pack/plugins/osquery/public/live_queries/index.tsx b/x-pack/plugins/osquery/public/live_queries/index.tsx index df119c9ad1412..b620d6d6aeec9 100644 --- a/x-pack/plugins/osquery/public/live_queries/index.tsx +++ b/x-pack/plugins/osquery/public/live_queries/index.tsx @@ -26,6 +26,7 @@ interface LiveQueryProps { agentPolicyIds?: string[]; onSuccess?: () => void; query?: string; + timeout?: number; savedQueryId?: string; ecs_mapping?: ECSMapping; agentsField?: boolean; @@ -55,6 +56,7 @@ const LiveQueryComponent: React.FC = ({ hideAgentsField, packId, agentSelection, + timeout, }) => { const { data: hasActionResultsPrivileges, isLoading } = useActionResultsPrivileges(); @@ -93,11 +95,12 @@ const LiveQueryComponent: React.FC = ({ query: initialQuery, savedQueryId, ecs_mapping, + timeout, packId, }; return !isEmpty(pickBy(initialValue, (value) => !isEmpty(value))) ? initialValue : undefined; - }, [alertIds, ecs_mapping, initialAgentSelection, initialQuery, packId, savedQueryId]); + }, [alertIds, ecs_mapping, initialAgentSelection, initialQuery, packId, savedQueryId, timeout]); if (isLoading) { return ; diff --git a/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx b/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx index b09acd4ae754d..e9fa1d34df207 100644 --- a/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx +++ b/x-pack/plugins/osquery/public/routes/saved_queries/list/index.tsx @@ -22,6 +22,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { useHistory } from 'react-router-dom'; import deepEqual from 'fast-deep-equal'; import type { ECSMapping } from '@kbn/osquery-io-ts-types'; +import { QUERY_TIMEOUT } from '../../../../common/constants'; import { Direction } from '../../../../common/search_strategy'; import { WithHeaderLayout } from '../../../components/layouts'; import { useBreadcrumbs } from '../../../common/hooks/use_breadcrumbs'; @@ -56,6 +57,7 @@ const PlayButtonComponent: React.FC = ({ disabled = false, save savedQueryId: savedQuery.id, query: savedQuery.query, ecs_mapping: savedQuery.ecs_mapping, + timeout: savedQuery.timeout ?? QUERY_TIMEOUT.DEFAULT, }, }), [push, savedQuery]