mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Infra] Fix: Processes tab shows toast with a 500 error when performing a full page refresh (#187459)
Closes #187385
## Summary
This PR fixes the issue with the processes tab showing a 500 error in a
toast when performing a full page refresh.
## Testing
Go to asset details and open the processes tab. Refresh the page: there
should not be any error visible.
8998d141
-8841-4138-8c76-7f555f6c44f0
This commit is contained in:
parent
d8614569e0
commit
f0edaa103b
7 changed files with 21 additions and 9 deletions
|
@ -14,7 +14,7 @@ const AggValueRT = rt.type({
|
|||
|
||||
export const ProcessListAPIRequestRT = rt.type({
|
||||
hostTerm: rt.record(rt.string, rt.string),
|
||||
indexPattern: rt.string,
|
||||
sourceId: rt.string,
|
||||
to: rt.number,
|
||||
sortBy: rt.type({
|
||||
name: rt.string,
|
||||
|
|
|
@ -26,10 +26,9 @@ export function useProcessList(
|
|||
to: number,
|
||||
sortBy: SortBy,
|
||||
searchFilter: object,
|
||||
sourceId: string,
|
||||
request$?: BehaviorSubject<(() => Promise<unknown>) | undefined>
|
||||
) {
|
||||
const { metricsView } = useMetricsDataViewContext();
|
||||
|
||||
const decodeResponse = (response: any) => {
|
||||
return pipe(
|
||||
ProcessListAPIResponseRT.decode(response),
|
||||
|
@ -50,7 +49,7 @@ export function useProcessList(
|
|||
'POST',
|
||||
JSON.stringify({
|
||||
hostTerm,
|
||||
indexPattern: metricsView?.indices,
|
||||
sourceId,
|
||||
to,
|
||||
sortBy: parsedSortBy,
|
||||
searchFilter,
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { EuiLoadingSpinner } from '@elastic/eui';
|
||||
import { getFieldByType } from '@kbn/metrics-data-access-plugin/common';
|
||||
import { useSourceContext } from '../../../../containers/metrics_source';
|
||||
import { parseSearchString } from './parse_search_string';
|
||||
import { ProcessesTable } from './processes_table';
|
||||
import { STATE_NAMES } from './states';
|
||||
|
@ -44,6 +45,8 @@ export const Processes = () => {
|
|||
const { getDateRangeInTimestamp } = useDatePickerContext();
|
||||
const [urlState, setUrlState] = useAssetDetailsUrlState();
|
||||
const { asset } = useAssetDetailsRenderPropsContext();
|
||||
const { sourceId } = useSourceContext();
|
||||
|
||||
const [searchText, setSearchText] = useState(urlState?.processSearch ?? '');
|
||||
const [searchQueryError, setSearchQueryError] = useState<Error | null>(null);
|
||||
const [searchBarState, setSearchBarState] = useState<Query>(() =>
|
||||
|
@ -75,6 +78,7 @@ export const Processes = () => {
|
|||
state.currentTimestamp,
|
||||
sortBy,
|
||||
parseSearchString(searchText),
|
||||
sourceId,
|
||||
request$
|
||||
);
|
||||
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
import { TIMESTAMP_FIELD, CMDLINE_FIELD } from '../../../common/constants';
|
||||
import { ProcessListAPIRequest, ProcessListAPIQueryAggregation } from '../../../common/http_api';
|
||||
import { ESSearchClient } from '../metrics/types';
|
||||
import type { InfraSourceConfiguration } from '../sources';
|
||||
|
||||
const TOP_N = 10;
|
||||
|
||||
export const getProcessList = async (
|
||||
search: ESSearchClient,
|
||||
{ hostTerm, indexPattern, to, sortBy, searchFilter }: ProcessListAPIRequest
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
{ hostTerm, to, sortBy, searchFilter }: ProcessListAPIRequest
|
||||
) => {
|
||||
const body = {
|
||||
size: 0,
|
||||
|
@ -111,7 +113,7 @@ export const getProcessList = async (
|
|||
try {
|
||||
const result = await search<{}, ProcessListAPIQueryAggregation>({
|
||||
body,
|
||||
index: indexPattern,
|
||||
index: sourceConfiguration.metricAlias,
|
||||
});
|
||||
const { buckets: processListBuckets } = result.aggregations!.processes.filteredProcs;
|
||||
const processList = processListBuckets.map((bucket) => {
|
||||
|
|
|
@ -41,7 +41,14 @@ export const initProcessListRoute = (libs: InfraBackendLibs) => {
|
|||
);
|
||||
|
||||
const client = createSearchClient(requestContext, framework);
|
||||
const processListResponse = await getProcessList(client, options);
|
||||
const soClient = (await requestContext.core).savedObjects.client;
|
||||
|
||||
const { configuration } = await libs.sources.getSourceConfiguration(
|
||||
soClient,
|
||||
options.sourceId
|
||||
);
|
||||
|
||||
const processListResponse = await getProcessList(client, configuration, options);
|
||||
|
||||
return response.ok({
|
||||
body: ProcessListAPIResponseRT.encode(processListResponse),
|
||||
|
|
|
@ -34,7 +34,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
hostTerm: {
|
||||
'host.name': 'gke-observability-8--observability-8--bc1afd95-nhhw',
|
||||
},
|
||||
indexPattern: 'metrics-*,metricbeat-*',
|
||||
sourceId: 'default',
|
||||
to: 1564432800000,
|
||||
sortBy: {
|
||||
name: 'cpu',
|
||||
|
|
|
@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
hostTerm: {
|
||||
'host.name': 'serverless-host',
|
||||
},
|
||||
indexPattern: 'metrics-*,metricbeat-*',
|
||||
sourceId: 'default',
|
||||
to: DATES.serverlessTestingHost.max,
|
||||
sortBy: {
|
||||
name: 'cpu',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue