From edf6a45e483ce469a69c69df4dd3f6b7761e4095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Wed, 18 Dec 2019 14:42:31 +0100 Subject: [PATCH 1/5] Implement `log_entries/item` api --- .../common/http_api/log_entries/index.ts | 1 + .../infra/common/http_api/log_entries/item.ts | 34 +++ .../plugins/infra/server/infra_server.ts | 2 + .../infra/server/routes/log_entries/index.ts | 1 + .../infra/server/routes/log_entries/item.ts | 55 ++++ .../api_integration/apis/infra/log_item.ts | 288 ++++++++---------- 6 files changed, 227 insertions(+), 154 deletions(-) create mode 100644 x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts create mode 100644 x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts b/x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts index ee2d150fdaac0..8fed914c3dc8c 100644 --- a/x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts +++ b/x-pack/legacy/plugins/infra/common/http_api/log_entries/index.ts @@ -4,5 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ +export * from './item'; export * from './summary'; export * from './summary_highlights'; diff --git a/x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts b/x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts new file mode 100644 index 0000000000000..7f35a98148360 --- /dev/null +++ b/x-pack/legacy/plugins/infra/common/http_api/log_entries/item.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as rt from 'io-ts'; + +export const LOG_ENTRIES_ITEM_PATH = '/api/log_entries/item'; + +export const logEntriesItemRequestRT = rt.type({ + sourceId: rt.string, + id: rt.string, +}); + +export type LogEntriesItemRequest = rt.TypeOf; + +const logEntriesItemFieldRT = rt.type({ field: rt.string, value: rt.string }); +const logEntriesItemRT = rt.type({ + id: rt.string, + index: rt.string, + fields: rt.array(logEntriesItemFieldRT), + key: rt.type({ + time: rt.number, + tiebreaker: rt.number, + }), +}); +export const logEntriesItemResponseRT = rt.type({ + data: logEntriesItemRT, +}); + +export type LogEntriesItemField = rt.TypeOf; +export type LogEntriesItem = rt.TypeOf; +export type LogEntriesItemResponse = rt.TypeOf; diff --git a/x-pack/legacy/plugins/infra/server/infra_server.ts b/x-pack/legacy/plugins/infra/server/infra_server.ts index f5a4bf8e8e054..108e1b1e3f392 100644 --- a/x-pack/legacy/plugins/infra/server/infra_server.ts +++ b/x-pack/legacy/plugins/infra/server/infra_server.ts @@ -22,6 +22,7 @@ import { initNodeDetailsRoute } from './routes/node_details'; import { initLogEntriesSummaryRoute, initLogEntriesSummaryHighlightsRoute, + initLogEntriesItemRoute, } from './routes/log_entries'; import { initInventoryMetaRoute } from './routes/inventory_metadata'; @@ -44,6 +45,7 @@ export const initInfraServer = (libs: InfraBackendLibs) => { initValidateLogAnalysisIndicesRoute(libs); initLogEntriesSummaryRoute(libs); initLogEntriesSummaryHighlightsRoute(libs); + initLogEntriesItemRoute(libs); initMetricExplorerRoute(libs); initMetadataRoute(libs); initInventoryMetaRoute(libs); diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts b/x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts index ee2d150fdaac0..8fed914c3dc8c 100644 --- a/x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts +++ b/x-pack/legacy/plugins/infra/server/routes/log_entries/index.ts @@ -4,5 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ +export * from './item'; export * from './summary'; export * from './summary_highlights'; diff --git a/x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts b/x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts new file mode 100644 index 0000000000000..22663cb2001f0 --- /dev/null +++ b/x-pack/legacy/plugins/infra/server/routes/log_entries/item.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import Boom from 'boom'; + +import { pipe } from 'fp-ts/lib/pipeable'; +import { fold } from 'fp-ts/lib/Either'; +import { identity } from 'fp-ts/lib/function'; +import { schema } from '@kbn/config-schema'; + +import { throwErrors } from '../../../common/runtime_types'; + +import { InfraBackendLibs } from '../../lib/infra_types'; +import { + LOG_ENTRIES_ITEM_PATH, + logEntriesItemRequestRT, + logEntriesItemResponseRT, +} from '../../../common/http_api'; + +const escapeHatch = schema.object({}, { allowUnknowns: true }); + +export const initLogEntriesItemRoute = ({ framework, sources, logEntries }: InfraBackendLibs) => { + framework.registerRoute( + { + method: 'post', + path: LOG_ENTRIES_ITEM_PATH, + validate: { body: escapeHatch }, + }, + async (requestContext, request, response) => { + try { + const payload = pipe( + logEntriesItemRequestRT.decode(request.body), + fold(throwErrors(Boom.badRequest), identity) + ); + + const { id, sourceId } = payload; + const sourceConfiguration = (await sources.getSourceConfiguration(requestContext, sourceId)) + .configuration; + + const logEntry = await logEntries.getLogItem(requestContext, id, sourceConfiguration); + + return response.ok({ + body: logEntriesItemResponseRT.encode({ + data: logEntry, + }), + }); + } catch (error) { + return response.internalError({ body: error.message }); + } + } + ); +}; diff --git a/x-pack/test/api_integration/apis/infra/log_item.ts b/x-pack/test/api_integration/apis/infra/log_item.ts index 2c1fc73de9595..bae2d0ebb891b 100644 --- a/x-pack/test/api_integration/apis/infra/log_item.ts +++ b/x-pack/test/api_integration/apis/infra/log_item.ts @@ -5,168 +5,148 @@ */ import expect from '@kbn/expect'; -import { flyoutItemQuery } from '../../../../legacy/plugins/infra/public/containers/logs/flyout_item.gql_query'; -import { FlyoutItemQuery } from '../../../../legacy/plugins/infra/public/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; +import { + LOG_ENTRIES_ITEM_PATH, + logEntriesItemRequestRT, +} from '../../../../legacy/plugins/infra/common/http_api'; + +const COMMON_HEADERS = { + 'kbn-xsrf': 'some-xsrf-token', +}; + export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const client = getService('infraOpsGraphQLClient'); - describe('Log Item GraphQL Endpoint', () => { + const supertest = getService('supertest'); + + describe('Log Item Endpoint', () => { before(() => esArchiver.load('infra/metrics_and_logs')); after(() => esArchiver.unload('infra/metrics_and_logs')); - it('should basically work', () => { - return client - .query({ - query: flyoutItemQuery, - variables: { + it('should basically work', async () => { + const { body } = await supertest + .post(LOG_ENTRIES_ITEM_PATH) + .set(COMMON_HEADERS) + .send( + logEntriesItemRequestRT.encode({ sourceId: 'default', - itemId: 'yT2Mg2YBh-opCxJv8Vqj', - }, - }) - .then(resp => { - expect(resp.data.source).to.have.property('logItem'); - const { logItem } = resp.data.source; - if (!logItem) { - throw new Error('Log item should not be falsey'); - } - expect(logItem).to.have.property('id', 'yT2Mg2YBh-opCxJv8Vqj'); - expect(logItem).to.have.property('index', 'filebeat-7.0.0-alpha1-2018.10.17'); - expect(logItem).to.have.property('fields'); - expect(logItem.fields).to.eql([ - { - field: '@timestamp', - value: '2018-10-17T19:42:22.000Z', - __typename: 'InfraLogItemField', - }, - { - field: '_id', - value: 'yT2Mg2YBh-opCxJv8Vqj', - __typename: 'InfraLogItemField', - }, - { - field: '_index', - value: 'filebeat-7.0.0-alpha1-2018.10.17', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.body_sent.bytes', - value: '1336', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.http_version', - value: '1.1', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.method', - value: 'GET', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.referrer', - value: '-', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.remote_ip', - value: '10.128.0.11', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.response_code', - value: '200', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.url', - value: '/a-fresh-start-will-put-you-on-your-way', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.user_agent.device', - value: 'Other', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.user_agent.name', - value: 'Other', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.user_agent.os', - value: 'Other', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.user_agent.os_name', - value: 'Other', - __typename: 'InfraLogItemField', - }, - { - field: 'apache2.access.user_name', - value: '-', - __typename: 'InfraLogItemField', - }, - { - field: 'beat.hostname', - value: 'demo-stack-apache-01', - __typename: 'InfraLogItemField', - }, - { - field: 'beat.name', - value: 'demo-stack-apache-01', - __typename: 'InfraLogItemField', - }, - { - field: 'beat.version', - value: '7.0.0-alpha1', - __typename: 'InfraLogItemField', - }, - { - field: 'fileset.module', - value: 'apache2', - __typename: 'InfraLogItemField', - }, - { - field: 'fileset.name', - value: 'access', - __typename: 'InfraLogItemField', - }, - { - field: 'host.name', - value: 'demo-stack-apache-01', - __typename: 'InfraLogItemField', - }, - { - field: 'input.type', - value: 'log', - __typename: 'InfraLogItemField', - }, - { - field: 'offset', - value: '5497614', - __typename: 'InfraLogItemField', - }, - { - field: 'prospector.type', - value: 'log', - __typename: 'InfraLogItemField', - }, - { - field: 'read_timestamp', - value: '2018-10-17T19:42:23.160Z', - __typename: 'InfraLogItemField', - }, - { - field: 'source', - value: '/var/log/apache2/access.log', - __typename: 'InfraLogItemField', - }, - ]); - }); + id: 'yT2Mg2YBh-opCxJv8Vqj', + }) + ) + .expect(200); + + const logItem = body.data; + + expect(logItem).to.have.property('id', 'yT2Mg2YBh-opCxJv8Vqj'); + expect(logItem).to.have.property('index', 'filebeat-7.0.0-alpha1-2018.10.17'); + expect(logItem).to.have.property('fields'); + expect(logItem.fields).to.eql([ + { + field: '@timestamp', + value: '2018-10-17T19:42:22.000Z', + }, + { + field: '_id', + value: 'yT2Mg2YBh-opCxJv8Vqj', + }, + { + field: '_index', + value: 'filebeat-7.0.0-alpha1-2018.10.17', + }, + { + field: 'apache2.access.body_sent.bytes', + value: '1336', + }, + { + field: 'apache2.access.http_version', + value: '1.1', + }, + { + field: 'apache2.access.method', + value: 'GET', + }, + { + field: 'apache2.access.referrer', + value: '-', + }, + { + field: 'apache2.access.remote_ip', + value: '10.128.0.11', + }, + { + field: 'apache2.access.response_code', + value: '200', + }, + { + field: 'apache2.access.url', + value: '/a-fresh-start-will-put-you-on-your-way', + }, + { + field: 'apache2.access.user_agent.device', + value: 'Other', + }, + { + field: 'apache2.access.user_agent.name', + value: 'Other', + }, + { + field: 'apache2.access.user_agent.os', + value: 'Other', + }, + { + field: 'apache2.access.user_agent.os_name', + value: 'Other', + }, + { + field: 'apache2.access.user_name', + value: '-', + }, + { + field: 'beat.hostname', + value: 'demo-stack-apache-01', + }, + { + field: 'beat.name', + value: 'demo-stack-apache-01', + }, + { + field: 'beat.version', + value: '7.0.0-alpha1', + }, + { + field: 'fileset.module', + value: 'apache2', + }, + { + field: 'fileset.name', + value: 'access', + }, + { + field: 'host.name', + value: 'demo-stack-apache-01', + }, + { + field: 'input.type', + value: 'log', + }, + { + field: 'offset', + value: '5497614', + }, + { + field: 'prospector.type', + value: 'log', + }, + { + field: 'read_timestamp', + value: '2018-10-17T19:42:23.160Z', + }, + { + field: 'source', + value: '/var/log/apache2/access.log', + }, + ]); }); }); } From 45ad64449cf5d112ba3451be0044fb62f6e5c299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Wed, 18 Dec 2019 15:06:17 +0100 Subject: [PATCH 2/5] Use endpoint in the `useLogFlyout` hook --- .../containers/logs/flyout_item.gql_query.ts | 29 ----------------- .../log_entries/api/fetch_log_entries_item.ts | 32 +++++++++++++++++++ .../public/containers/logs/log_flyout.tsx | 25 +++------------ 3 files changed, 37 insertions(+), 49 deletions(-) delete mode 100644 x-pack/legacy/plugins/infra/public/containers/logs/flyout_item.gql_query.ts create mode 100644 x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/flyout_item.gql_query.ts b/x-pack/legacy/plugins/infra/public/containers/logs/flyout_item.gql_query.ts deleted file mode 100644 index 2c51bdbb46e89..0000000000000 --- a/x-pack/legacy/plugins/infra/public/containers/logs/flyout_item.gql_query.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import gql from 'graphql-tag'; -import { sharedFragments } from '../../../common/graphql/shared'; - -export const flyoutItemQuery = gql` - query FlyoutItemQuery($sourceId: ID!, $itemId: ID!) { - source(id: $sourceId) { - id - logItem(id: $itemId) { - id - index - key { - ...InfraTimeKeyFields - } - fields { - field - value - } - } - } - } - - ${sharedFragments.InfraTimeKey} -`; diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts b/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts new file mode 100644 index 0000000000000..fd093f20dd490 --- /dev/null +++ b/x-pack/legacy/plugins/infra/public/containers/logs/log_entries/api/fetch_log_entries_item.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { fold } from 'fp-ts/lib/Either'; +import { pipe } from 'fp-ts/lib/pipeable'; +import { identity } from 'fp-ts/lib/function'; +import { kfetch } from 'ui/kfetch'; + +import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; + +import { + LOG_ENTRIES_ITEM_PATH, + LogEntriesItemRequest, + logEntriesItemRequestRT, + logEntriesItemResponseRT, +} from '../../../../../common/http_api'; + +export const fetchLogEntriesItem = async (requestArgs: LogEntriesItemRequest) => { + const response = await kfetch({ + method: 'POST', + pathname: LOG_ENTRIES_ITEM_PATH, + body: JSON.stringify(logEntriesItemRequestRT.encode(requestArgs)), + }); + + return pipe( + logEntriesItemResponseRT.decode(response), + fold(throwErrors(createPlainError), identity) + ); +}; diff --git a/x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx b/x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx index 53b962c7de5a7..5354964ebda78 100644 --- a/x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx +++ b/x-pack/legacy/plugins/infra/public/containers/logs/log_flyout.tsx @@ -8,12 +8,11 @@ import createContainer from 'constate'; import { isString } from 'lodash'; import React, { useContext, useEffect, useMemo, useState } from 'react'; -import { FlyoutItemQuery, InfraLogItem } from '../../graphql/types'; -import { useApolloClient } from '../../utils/apollo_context'; +import { InfraLogItem } from '../../graphql/types'; import { UrlStateContainer } from '../../utils/url_state'; import { useTrackedPromise } from '../../utils/use_tracked_promise'; import { Source } from '../source'; -import { flyoutItemQuery } from './flyout_item.gql_query'; +import { fetchLogEntriesItem } from './log_entries/api/fetch_log_entries_item'; export enum FlyoutVisibility { hidden = 'hidden', @@ -33,37 +32,23 @@ export const useLogFlyout = () => { const [flyoutItem, setFlyoutItem] = useState(null); const [surroundingLogsId, setSurroundingLogsId] = useState(null); - const apolloClient = useApolloClient(); - const [loadFlyoutItemRequest, loadFlyoutItem] = useTrackedPromise( { cancelPreviousOn: 'creation', createPromise: async () => { - if (!apolloClient) { - throw new Error('Failed to load flyout item: No apollo client available.'); - } - if (!flyoutId) { return; } - - return await apolloClient.query({ - fetchPolicy: 'no-cache', - query: flyoutItemQuery, - variables: { - itemId: flyoutId, - sourceId, - }, - }); + return await fetchLogEntriesItem({ sourceId, id: flyoutId }); }, onResolve: response => { if (response) { const { data } = response; - setFlyoutItem((data && data.source && data.source.logItem) || null); + setFlyoutItem(data || null); } }, }, - [apolloClient, sourceId, flyoutId] + [sourceId, flyoutId] ); const isLoading = useMemo(() => { From 006488d59faea83925f2c04f41a18fbf446d2c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Wed, 18 Dec 2019 15:34:30 +0100 Subject: [PATCH 3/5] Clean up GraphQL implementation and types --- .../plugins/infra/common/graphql/types.ts | 65 -------- .../log_entry_actions_menu.tsx | 8 +- .../log_entry_flyout/log_entry_flyout.tsx | 8 +- .../public/containers/logs/log_flyout.tsx | 4 +- .../infra/public/graphql/introspection.json | 146 +++--------------- .../plugins/infra/public/graphql/types.ts | 65 -------- .../server/graphql/log_entries/resolvers.ts | 22 --- .../server/graphql/log_entries/schema.gql.ts | 19 --- .../plugins/infra/server/graphql/types.ts | 88 +---------- ...vert_document_source_to_log_item_fields.ts | 6 +- .../log_entries_domain/log_entries_domain.ts | 5 +- 11 files changed, 35 insertions(+), 401 deletions(-) diff --git a/x-pack/legacy/plugins/infra/common/graphql/types.ts b/x-pack/legacy/plugins/infra/common/graphql/types.ts index bd1d3945f35f7..bb089bf8bf8ad 100644 --- a/x-pack/legacy/plugins/infra/common/graphql/types.ts +++ b/x-pack/legacy/plugins/infra/common/graphql/types.ts @@ -35,7 +35,6 @@ export interface InfraSource { /** Sequences of log entries matching sets of highlighting queries within an interval */ logEntryHighlights: InfraLogEntryInterval[]; - logItem: InfraLogItem; /** A snapshot of nodes */ snapshot?: InfraSnapshotResponse | null; @@ -205,24 +204,6 @@ export interface InfraLogEntryFieldColumn { highlights: string[]; } -export interface InfraLogItem { - /** The ID of the document */ - id: string; - /** The index where the document was found */ - index: string; - /** Time key for the document - derived from the source configuration timestamp and tiebreaker settings */ - key: InfraTimeKey; - /** An array of flattened fields and values */ - fields: InfraLogItemField[]; -} - -export interface InfraLogItemField { - /** The flattened field name */ - field: string; - /** The value for the Field as a string */ - value: string; -} - export interface InfraSnapshotResponse { /** Nodes of type host, container or pod grouped by 0, 1 or 2 terms */ nodes: InfraSnapshotNode[]; @@ -424,9 +405,6 @@ export interface LogEntryHighlightsInfraSourceArgs { /** The highlighting to apply to the log entries */ highlights: InfraLogEntryHighlightInput[]; } -export interface LogItemInfraSourceArgs { - id: string; -} export interface SnapshotInfraSourceArgs { timerange: InfraTimerangeInput; @@ -600,49 +578,6 @@ export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessa // Documents // ==================================================== -export namespace FlyoutItemQuery { - export type Variables = { - sourceId: string; - itemId: string; - }; - - export type Query = { - __typename?: 'Query'; - - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - - id: string; - - logItem: LogItem; - }; - - export type LogItem = { - __typename?: 'InfraLogItem'; - - id: string; - - index: string; - - key: Key; - - fields: Fields[]; - }; - - export type Key = InfraTimeKeyFields.Fragment; - - export type Fields = { - __typename?: 'InfraLogItemField'; - - field: string; - - value: string; - }; -} - export namespace LogEntryHighlightsQuery { export type Variables = { sourceId?: string | null; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx index 0d20e7b733dfa..2af754dde208f 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx @@ -10,14 +10,14 @@ import React, { useMemo } from 'react'; import url from 'url'; import chrome from 'ui/chrome'; -import { InfraLogItem } from '../../../graphql/types'; import { useVisibilityState } from '../../../utils/use_visibility_state'; import { getTraceUrl } from '../../../../../apm/public/components/shared/Links/apm/ExternalLinks'; +import { LogEntriesItem } from '../../../../common/http_api'; const UPTIME_FIELDS = ['container.id', 'host.ip', 'kubernetes.pod.uid']; export const LogEntryActionsMenu: React.FunctionComponent<{ - logItem: InfraLogItem; + logItem: LogEntriesItem; }> = ({ logItem }) => { const { hide, isVisible, show } = useVisibilityState(false); @@ -84,7 +84,7 @@ export const LogEntryActionsMenu: React.FunctionComponent<{ ); }; -const getUptimeLink = (logItem: InfraLogItem) => { +const getUptimeLink = (logItem: LogEntriesItem) => { const searchExpressions = logItem.fields .filter(({ field, value }) => value != null && UPTIME_FIELDS.includes(field)) .map(({ field, value }) => `${field}:${value}`); @@ -99,7 +99,7 @@ const getUptimeLink = (logItem: InfraLogItem) => { }); }; -const getAPMLink = (logItem: InfraLogItem) => { +const getAPMLink = (logItem: LogEntriesItem) => { const traceIdEntry = logItem.fields.find( ({ field, value }) => value != null && field === 'trace.id' ); diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx index ed61c70afb73f..d2cb9cf9370dd 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx @@ -22,12 +22,12 @@ import React, { useCallback, useMemo } from 'react'; import euiStyled from '../../../../../../common/eui_styled_components'; import { TimeKey } from '../../../../common/time'; -import { InfraLogItem, InfraLogItemField } from '../../../graphql/types'; import { InfraLoadingPanel } from '../../loading'; import { LogEntryActionsMenu } from './log_entry_actions_menu'; +import { LogEntriesItem, LogEntriesItemField } from '../../../../common/http_api'; interface Props { - flyoutItem: InfraLogItem | null; + flyoutItem: LogEntriesItem | null; setFlyoutVisibility: (visible: boolean) => void; setFilter: (filter: string) => void; setTarget: (timeKey: TimeKey, flyoutItemId: string) => void; @@ -43,7 +43,7 @@ export const LogEntryFlyout = ({ setTarget, }: Props) => { const createFilterHandler = useCallback( - (field: InfraLogItemField) => () => { + (field: LogEntriesItemField) => () => { const filter = `${field.field}:"${field.value}"`; setFilter(filter); @@ -80,7 +80,7 @@ export const LogEntryFlyout = ({ defaultMessage: 'Value', }), sortable: true, - render: (_name: string, item: InfraLogItemField) => ( + render: (_name: string, item: LogEntriesItemField) => (