forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM][ECO] Add link "Explore logs" in logs charts (elastic#191704)
## Summary closes elastic#190520 https://github.com/user-attachments/assets/7adce001-3a39-412e-aeeb-adc11e5be72e --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
631304b
commit ddc42ee
Showing
5 changed files
with
211 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ability_solution/apm/public/components/shared/explore_logs_button/explore_logs_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you ∏may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { AllDatasetsLocatorParams, ALL_DATASETS_LOCATOR_ID } from '@kbn/deeplinks-observability'; | ||
import { EuiButtonEmpty } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context'; | ||
import { buildLogsExplorerLocatorConfig } from './logs_explorer_locator_config'; | ||
|
||
export function ExploreLogsButton({ | ||
start, | ||
end, | ||
kuery, | ||
}: { | ||
start: string; | ||
end: string; | ||
kuery?: string; | ||
}) { | ||
const { share } = useApmPluginContext(); | ||
|
||
const logsExplorerLocator = | ||
share.url.locators.get<AllDatasetsLocatorParams>(ALL_DATASETS_LOCATOR_ID)!; | ||
|
||
if (!logsExplorerLocator) { | ||
return null; | ||
} | ||
|
||
const { logsExplorerLinkProps } = buildLogsExplorerLocatorConfig({ | ||
locator: logsExplorerLocator, | ||
from: start, | ||
to: end, | ||
kuery, | ||
}); | ||
|
||
return ( | ||
<EuiButtonEmpty | ||
data-test-subj="apmExploreLogsButton" | ||
href={logsExplorerLinkProps.href} | ||
color="primary" | ||
> | ||
{i18n.translate('xpack.apm.button.exploreLogs', { | ||
defaultMessage: 'Explore logs', | ||
})} | ||
</EuiButtonEmpty> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
...solution/apm/public/components/shared/explore_logs_button/logs_explorer_locator_config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AllDatasetsLocatorParams } from '@kbn/deeplinks-observability'; | ||
import { LocatorPublic } from '@kbn/share-plugin/common'; | ||
import { getRouterLinkProps } from '@kbn/router-utils'; | ||
import { RouterLinkProps } from '@kbn/router-utils/src/get_router_link_props'; | ||
|
||
export const buildLogsExplorerLocatorConfig = ({ | ||
locator, | ||
kuery, | ||
from, | ||
to, | ||
}: { | ||
locator: LocatorPublic<AllDatasetsLocatorParams>; | ||
kuery?: string; | ||
from: string; | ||
to: string; | ||
}): { | ||
logsExplorerLinkProps: RouterLinkProps; | ||
} => { | ||
const params: AllDatasetsLocatorParams = { | ||
timeRange: { | ||
from, | ||
to, | ||
}, | ||
...(kuery && { | ||
query: { language: 'kuery', query: kuery }, | ||
}), | ||
}; | ||
|
||
const urlToLogsExplorer = locator.getRedirectUrl(params); | ||
|
||
const navigateToLogsExplorer = () => { | ||
locator.navigate(params); | ||
}; | ||
|
||
const logsExplorerLinkProps = getRouterLinkProps({ | ||
href: urlToLogsExplorer, | ||
onClick: navigateToLogsExplorer, | ||
}); | ||
|
||
return { logsExplorerLinkProps }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters