Skip to content

Commit

Permalink
[Dataset Quality] Check if Obs Logs Explorer accessible before linkin…
Browse files Browse the repository at this point in the history
…g Logs Explorer (elastic#197020)

Fixes elastic#196506

## Summary

Before linking to Logs Explorer in Dataset Quality, the PR checks if
`observability-logs-explorer` is available and accessible before
consuming the `SINGLE_DATASET_LOCATOR_ID` locator.

Observability Logs Explorer app is not available in Security and Search
solution views.


After the fix:


https://github.com/user-attachments/assets/ed36806a-0483-4765-a6f1-85936b92d390



There's only one more place, Observability Onboarding, where
`SINGLE_DATASET_LOCATOR_ID` is consumed. Which being part of
Observability solution view, it can be assumed that Observability Logs
Explorer will always be available.


![image](https://github.com/user-attachments/assets/b51bf9b6-a9c4-4fd4-8865-3dda76262a93)

----

The other Observability Logs Explorer locator `ALL_DATASETS_LOCATOR_ID`
is only consumed in observability wrapper apps and `apm` and `infra`
plugins, all of which are only available under Observability where
Observability Logs Explorer is also available.

https://github.com/elastic/kibana/blob/68b3267ca2f76d8de4fedef622608d8685e7eceb/packages/deeplinks/observability/locators/observability_logs_explorer.ts#L24

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
awahab07 and kibanamachine authored Oct 22, 2024
1 parent b89941f commit c076b7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
* 2.0.
*/

import { map } from 'rxjs';
import { useMemo } from 'react';
import useObservable from 'react-use/lib/useObservable';
import { AppStatus } from '@kbn/core-application-browser';
import {
OBSERVABILITY_LOGS_EXPLORER_APP_ID,
SINGLE_DATASET_LOCATOR_ID,
SingleDatasetLocatorParams,
} from '@kbn/deeplinks-observability';
Expand Down Expand Up @@ -34,20 +38,32 @@ export const useRedirectLink = <T extends BasicDataStream>({
sendTelemetry: SendTelemetryFn;
}) => {
const {
services: { share },
services: { share, application },
} = useKibanaContextForPlugin();

const { from, to } = timeRangeConfig;

const logsExplorerLocator =
share.url.locators.get<SingleDatasetLocatorParams>(SINGLE_DATASET_LOCATOR_ID);

const isLogsExplorerAppAccessible = useObservable(
application.applications$.pipe(
map(
(apps) =>
(apps.get(OBSERVABILITY_LOGS_EXPLORER_APP_ID)?.status ?? AppStatus.inaccessible) ===
AppStatus.accessible
)
),
false
);

return useMemo<{
linkProps: RouterLinkProps;
navigate: () => void;
isLogsExplorerAvailable: boolean;
}>(() => {
const isLogsExplorerAvailable = !!logsExplorerLocator && dataStreamStat.type === 'logs';
const isLogsExplorerAvailable =
isLogsExplorerAppAccessible && !!logsExplorerLocator && dataStreamStat.type === 'logs';
const config = isLogsExplorerAvailable
? buildLogsExplorerConfig({
locator: logsExplorerLocator,
Expand Down Expand Up @@ -95,6 +111,7 @@ export const useRedirectLink = <T extends BasicDataStream>({
query,
sendTelemetry,
share.url.locators,
isLogsExplorerAppAccessible,
]);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"@kbn/telemetry-plugin",
"@kbn/usage-collection-plugin",
"@kbn/rison",
"@kbn/task-manager-plugin"
"@kbn/task-manager-plugin",
"@kbn/core-application-browser"
],
"exclude": [
"target/**/*"
Expand Down

0 comments on commit c076b7a

Please sign in to comment.