[Logs] using All logs dataview in LOGS_LOCATOR (#211549)

Closes https://github.com/elastic/kibana/issues/209122.

### 🎥  Demo


https://github.com/user-attachments/assets/34d8b544-3ff6-4332-8856-57014fb1fc8a

### How to test?
1. Ingest some data using `logs_and_metrics` synthtrace scenario
2. Go to `/app/observability/overview` or `app/metrics/hosts`
3. Click `logs` link
4. You should be redirected to discover and `All logs` should be set by
default

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Yngrid Coello 2025-03-06 21:38:00 +01:00 committed by GitHub
parent bdbc2ef43f
commit 989cf1ec34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 16 deletions

View file

@ -54,7 +54,7 @@ export const ViewLogsButton: React.FunctionComponent<ViewLogsProps> = ({
from: getTimeRangeStartFromTime(startTime ? startTime : defaultStartTime),
to: getTimeRangeEndFromTime(endTime ? endTime : defaultEndTime),
},
filter: logStreamQuery,
query: { language: 'kuery', query: logStreamQuery },
});
}, [endTime, logStreamQuery, logsLocator, startTime]);

View file

@ -5,11 +5,11 @@
* 2.0.
*/
import type { DiscoverAppLocatorParams } from '@kbn/discover-plugin/common';
import { type DiscoverAppLocatorParams } from '@kbn/discover-plugin/common';
import { ALL_LOGS_DATA_VIEW_ID } from '@kbn/discover-utils/src';
import type { LogsDataAccessPluginStart } from '@kbn/logs-data-access-plugin/public';
import { LocatorDefinition } from '@kbn/share-plugin/common';
import { LocatorClient } from '@kbn/share-plugin/common/url_service';
import type { LogsDataAccessPluginStart } from '@kbn/logs-data-access-plugin/public';
import type { DataViewSpec } from '@kbn/data-views-plugin/common';
/**
* Locator used to link to all log sources in Discover.
@ -17,7 +17,7 @@ import type { DataViewSpec } from '@kbn/data-views-plugin/common';
export const LOGS_LOCATOR_ID = 'LOGS_LOCATOR';
/**
* Accepts the same parameters as `DiscoverAppLocatorParams`, but automatically sets the `dataViewSpec` param to all log sources.
* Accepts the same parameters as `DiscoverAppLocatorParams`, but automatically sets the `dataViewId` param to all log sources.
*/
export type LogsLocatorParams = DiscoverAppLocatorParams;
@ -36,17 +36,8 @@ export class LogsLocatorDefinition implements LocatorDefinition<LogsLocatorParam
this.deps.locators.get<DiscoverAppLocatorParams>('DISCOVER_APP_LOCATOR')!;
return discoverAppLocator.getLocation({
dataViewSpec: params.dataViewSpec ?? (await this.getLogSourcesDataViewSpec()),
dataViewId: ALL_LOGS_DATA_VIEW_ID,
...params,
});
};
private async getLogSourcesDataViewSpec(): Promise<DataViewSpec> {
const logSourcesService = await this.deps.getLogSourcesService();
const logSources = await logSourcesService.getLogSources();
return {
title: logSources.map((logSource) => logSource.indexPattern).join(','),
timeFieldName: '@timestamp',
};
}
}

View file

@ -31,7 +31,7 @@
],
"requiredBundles": [
"kibanaUtils",
"kibanaReact"
"kibanaReact",
],
"extraPublicDirs": [
"common"

View file

@ -58,5 +58,6 @@
"@kbn/analytics",
"@kbn/usage-collection-plugin",
"@kbn/deeplinks-management",
"@kbn/discover-utils",
]
}