From 2d3dc3fc875d4e4720190de75d34d6838f267e55 Mon Sep 17 00:00:00 2001 From: jennypavlova Date: Mon, 10 Jun 2024 14:57:01 +0200 Subject: [PATCH] [Infra] Add the logs tab to container views (#184854) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #184770 ## Summary This PR adds the logs tab to container views. ### Testing - Enable Container view from Infra settings - Go to Inventory and select Docker Containers from the "Show" drop-down - Click on a container - The logs tab should be visible - Click on the Logs tab - The search functionality and the link (with the filter) should work ![image](https://github.com/elastic/kibana/assets/14139027/c0720a47-50e5-4244-9f50-53882fc5ed53) - Click on "Open as Page" - The logs tab should be visible - The search functionality and the link (with the filter) should work image https://github.com/elastic/kibana/assets/14139027/0ce5761c-cc39-4d55-87ba-a6c12cc7315c - ⚠️ If some of the containers on the edge cluster don't have logs in the logs settings the `container.id` can be added and used in inventory to find a container with logs ( This should be added for the docker containers on edge soon - for now it can be checked for a non-docker container ) ![image](https://github.com/elastic/kibana/assets/14139027/90d7f0e4-384d-4cc8-aea0-6ff10713450d) Example with a container id (with logs) ![image](https://github.com/elastic/kibana/assets/14139027/162f37ce-8ba8-4c8d-835d-f2d23c3bc0ec) --- .../asset_details_tabs.tsx | 6 ++--- .../test/functional/apps/infra/home_page.ts | 16 +++++++++++++ .../functional/apps/infra/node_details.ts | 23 +++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/common/asset_details_config/asset_details_tabs.tsx b/x-pack/plugins/observability_solution/infra/public/common/asset_details_config/asset_details_tabs.tsx index c7f4b9f497a52..173d39726292f 100644 --- a/x-pack/plugins/observability_solution/infra/public/common/asset_details_config/asset_details_tabs.tsx +++ b/x-pack/plugins/observability_solution/infra/public/common/asset_details_config/asset_details_tabs.tsx @@ -110,9 +110,9 @@ export const hostDetailsTabs: Tab[] = [ ]; export const hostDetailsFlyoutTabs: Tab[] = [...hostDetailsTabs, linkToApmTab]; -// Profiling and Logs tab would be added in next iteration -export const containerDetailsTabs: Tab[] = [overviewTab, metadataTab]; -export const containerDetailsFlyoutTabs: Tab[] = [overviewTab, metadataTab, linkToApmTab]; +// The profiling tab would be added in next iteration +export const containerDetailsTabs: Tab[] = [overviewTab, metadataTab, logsTab]; +export const containerDetailsFlyoutTabs: Tab[] = [overviewTab, metadataTab, logsTab, linkToApmTab]; export const getAssetDetailsTabs = (type: string): Tab[] => { switch (type) { diff --git a/x-pack/test/functional/apps/infra/home_page.ts b/x-pack/test/functional/apps/infra/home_page.ts index e197715aadedf..669547c1c671c 100644 --- a/x-pack/test/functional/apps/infra/home_page.ts +++ b/x-pack/test/functional/apps/infra/home_page.ts @@ -328,6 +328,22 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); }); + describe('Logs Tab', () => { + before(async () => { + await pageObjects.assetDetails.clickLogsTab(); + }); + + after(async () => { + await retry.try(async () => { + await pageObjects.infraHome.closeFlyout(); + }); + }); + + it('should render logs tab', async () => { + await pageObjects.assetDetails.logsExists(); + }); + }); + describe('APM Link Tab', () => { before(async () => { await pageObjects.infraHome.clickOnNode(); diff --git a/x-pack/test/functional/apps/infra/node_details.ts b/x-pack/test/functional/apps/infra/node_details.ts index 4318644c81bb5..1cc435e417437 100644 --- a/x-pack/test/functional/apps/infra/node_details.ts +++ b/x-pack/test/functional/apps/infra/node_details.ts @@ -670,6 +670,29 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(charts.length).to.equal(chartsCount); }); }); + describe('Logs Tab', () => { + before(async () => { + await pageObjects.assetDetails.clickLogsTab(); + }); + + it('should render logs tab', async () => { + await pageObjects.assetDetails.logsExists(); + }); + + it('preserves search term between page reloads', async () => { + const searchInput = await pageObjects.assetDetails.getLogsSearchField(); + + expect(await searchInput.getAttribute('value')).to.be(''); + + await searchInput.type('test'); + await refreshPageWithDelay(); + + await retry.try(async () => { + expect(await searchInput.getAttribute('value')).to.be('test'); + }); + await searchInput.clearValue(); + }); + }); }); }); });