[Dataset quality] Pass breakdown field over to logs explorer from degraded docs chart (#181509)

## Summary

The PR adds the `breakdownField` param in `LogsExplorerNavigationParams`
so that when "Explorer data in Logs Explorer" is clicked on Degraded
Docs chart on Dataset Quality flyout while the chart has a breakdown
field selected, the field is passed over to Logs Explorer.



b380ac85-e40e-451b-983f-41c68f87ed7b
This commit is contained in:
Abdul Wahab Zahid 2024-04-24 15:27:08 +02:00 committed by GitHub
parent 58562c9565
commit 707ec552d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 1 deletions

View file

@ -68,6 +68,10 @@ export interface LogsExplorerNavigationParams extends SerializableRecord {
* Optionally apply curated filter controls
*/
filterControls?: FilterControls;
/**
* Optionally set chart's breakdown field
*/
breakdownField?: string;
}
export interface LogsExplorerLocatorParams extends LogsExplorerNavigationParams {

View file

@ -99,6 +99,21 @@ describe('Observability Logs Explorer Locators', () => {
});
});
it('should allow specifying breakdown field', async () => {
const params: AllDatasetsLocatorParams = {
breakdownField: 'service.name',
};
const { allDatasetsLocator } = await setup();
const location = await allDatasetsLocator.getLocation(params);
expect(location).toMatchObject({
app: OBSERVABILITY_LOGS_EXPLORER_APP_ID,
path: '/?pageState=(breakdownField:service.name,dataSourceSelection:(selectionType:all),v:2)',
state: {},
});
});
it('should allow specifying columns', async () => {
const params: AllDatasetsLocatorParams = {
columns: [{ field: '_source', type: 'document-field' }],
@ -211,6 +226,22 @@ describe('Observability Logs Explorer Locators', () => {
});
});
it('should allow specifying breakdown field', async () => {
const params: ObsLogsExplorerDataViewLocatorParams = {
id: 'data-view-id',
breakdownField: 'service.name',
};
const { dataViewLocator } = await setup();
const location = await dataViewLocator.getLocation(params);
expect(location).toMatchObject({
app: OBSERVABILITY_LOGS_EXPLORER_APP_ID,
path: `/?pageState=(breakdownField:service.name,dataSourceSelection:(selection:(dataView:(dataType:unresolved,id:data-view-id)),selectionType:dataView),v:2)`,
state: {},
});
});
it('should allow specifying columns', async () => {
const params: ObsLogsExplorerDataViewLocatorParams = {
id: 'data-view-id',
@ -331,6 +362,23 @@ describe('Observability Logs Explorer Locators', () => {
});
});
it('should allow specifying breakdown field', async () => {
const params: SingleDatasetLocatorParams = {
integration,
dataset,
breakdownField: 'service.name',
};
const { singleDatasetLocator } = await setup();
const location = await singleDatasetLocator.getLocation(params);
expect(location).toMatchObject({
app: OBSERVABILITY_LOGS_EXPLORER_APP_ID,
path: `/?pageState=(breakdownField:service.name,dataSourceSelection:(selection:(dataset:(name:'logs-test-*-*',title:test),name:Test),selectionType:unresolved),v:2)`,
state: {},
});
});
it('should allow specifying columns', async () => {
const params: SingleDatasetLocatorParams = {
integration,

View file

@ -35,7 +35,16 @@ interface LocatorPathConstructionParams {
export const constructLocatorPath = async (params: LocatorPathConstructionParams) => {
const {
dataSourceSelection,
locatorParams: { filterControls, filters, query, refreshInterval, timeRange, columns, origin },
locatorParams: {
filterControls,
filters,
query,
refreshInterval,
timeRange,
columns,
origin,
breakdownField,
},
useHash,
} = params;
@ -47,6 +56,7 @@ export const constructLocatorPath = async (params: LocatorPathConstructionParams
query,
refreshInterval,
time: timeRange,
breakdownField,
columns: columns?.map((column) => {
return column.type === 'smart-field' ? SMART_FALLBACK_FIELDS[column.smartField] : column;
}),