Skip to content

Commit

Permalink
[Logs Explorer] Add logic to render degraded fields table in Logs Fly…
Browse files Browse the repository at this point in the history
…out (#186287)

## Summary

Closes - #172272
The PR adds the degraded Field Table in the Logs Flyout. The accordion
is kept closed by default. For demo purposes below screenshot will show
it expanded

This PR will also fix a very simply Flaky Test -
#186244

## Pending Items

- [x] Add Locator for Dataset Quality Page
- [x] Add tests


## Demo

![Jul-04-2024
15-54-22](https://github.com/elastic/kibana/assets/7416358/4ff9ab9c-ef01-4dd4-83f0-8db9e0dad3f1)

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
achyutjhunjhunwala and kibanamachine authored Jul 9, 2024
1 parent 0b9751b commit 2e8ca07
Show file tree
Hide file tree
Showing 22 changed files with 409 additions and 55 deletions.
15 changes: 13 additions & 2 deletions packages/deeplinks/observability/locators/dataset_quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { SerializableRecord } from '@kbn/utility-types';

export const DATASET_QUALITY_LOCATOR_ID = 'DATASET_QUALITY_LOCATOR';
export const DATA_QUALITY_LOCATOR_ID = 'DATA_QUALITY_LOCATOR';

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RefreshInterval = {
Expand All @@ -23,11 +23,22 @@ type TimeRangeConfig = {
refresh: RefreshInterval;
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type DatasetConfig = {
rawName: string;
type: string;
name: string;
namespace: string;
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Filters = {
timeRange: TimeRangeConfig;
};

export interface DatasetQualityLocatorParams extends SerializableRecord {
export interface DataQualityLocatorParams extends SerializableRecord {
filters?: Filters;
flyout?: {
dataset: DatasetConfig;
};
}
2 changes: 1 addition & 1 deletion src/plugins/unified_doc_viewer/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"server": false,
"browser": true,
"requiredBundles": ["kibanaUtils"],
"requiredPlugins": ["data", "discoverShared", "fieldFormats"],
"requiredPlugins": ["data", "discoverShared", "fieldFormats", "share"],
"optionalPlugins": ["fieldsMetadata"]
}
}
2 changes: 2 additions & 0 deletions src/plugins/unified_doc_viewer/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { discoverSharedPluginMock } from '@kbn/discover-shared-plugin/public/moc
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { fieldsMetadataPluginPublicMock } from '@kbn/fields-metadata-plugin/public/mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import type { UnifiedDocViewerServices, UnifiedDocViewerStart } from '../types';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DocViewsRegistry } from '@kbn/unified-doc-viewer';
Expand All @@ -29,4 +30,5 @@ export const mockUnifiedDocViewerServices: jest.Mocked<UnifiedDocViewerServices>
storage: new Storage(localStorage),
uiSettings: uiSettingsServiceMock.createStartContract(),
unifiedDocViewer: mockUnifiedDocViewer,
share: sharePluginMock.createStartContract(),
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const DATASET_NAME = 'logs.overview';
const NAMESPACE = 'default';
const DATA_STREAM_NAME = `logs-${DATASET_NAME}-${NAMESPACE}`;
const NOW = Date.now();
const MORE_THAN_1024_CHARS =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?';

const dataView = {
fields: {
Expand Down Expand Up @@ -82,7 +84,7 @@ const fullHit = buildDataTableRecord(
cloud: {
provider: ['gcp'],
region: 'us-central-1',
availability_zone: 'us-central-1a',
availability_zone: MORE_THAN_1024_CHARS,
project: {
id: 'elastic-project',
},
Expand All @@ -92,6 +94,9 @@ const fullHit = buildDataTableRecord(
},
'agent.name': 'node',
},
ignored_field_values: {
'cloud.availability_zone': [MORE_THAN_1024_CHARS],
},
},
dataView
);
Expand Down Expand Up @@ -159,4 +164,37 @@ describe('LogsOverview', () => {
expect(screen.queryByTestId('unifiedDocViewLogsOverviewLogShipper')).toBeInTheDocument();
});
});
describe('Degraded Fields section', () => {
it('should load the degraded fields container when present', async () => {
expect(
screen.queryByTestId('unifiedDocViewLogsOverviewDegradedFieldsAccordion')
).toBeInTheDocument();
expect(
screen.queryByTestId('unifiedDocViewLogsOverviewDegradedFieldsTechPreview')
).toBeInTheDocument();
expect(
screen.queryByTestId('unifiedDocViewLogsOverviewDegradedFieldTitleCount')
).toBeInTheDocument();

// The accordion must be closed by default
const accordion = screen.queryByTestId('unifiedDocViewLogsOverviewDegradedFieldsAccordion1');

if (accordion === null) {
return;
}
const button = accordion.querySelector('button');

if (button === null) {
return;
}
// Check the aria-expanded property of the button
const isExpanded = button.getAttribute('aria-expanded');
expect(isExpanded).toBe('false');

button.click();
expect(
screen.queryByTestId('unifiedDocViewLogsOverviewDegradedFieldsQualityIssuesTable')
).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { LogsOverviewHighlights } from './logs_overview_highlights';
import { FieldActionsProvider } from '../../hooks/use_field_actions';
import { getUnifiedDocViewerServices } from '../../plugin';
import { LogsOverviewAIAssistant } from './logs_overview_ai_assistant';
import { LogsOverviewDegradedFields } from './logs_overview_degraded_fields';

export function LogsOverview({
columns,
Expand All @@ -38,6 +39,7 @@ export function LogsOverview({
<LogsOverviewHeader doc={parsedDoc} />
<EuiHorizontalRule margin="xs" />
<LogsOverviewHighlights formattedDoc={parsedDoc} flattenedDoc={hit.flattened} />
<LogsOverviewDegradedFields rawDoc={hit.raw} />
<LogsOverviewAIAssistant doc={hit} />
</FieldActionsProvider>
);
Expand Down
Loading

0 comments on commit 2e8ca07

Please sign in to comment.