Skip to content

Commit a8913d3

Browse files
authored
[Fleet] Agent logs UI (#83356)
* Initial agent log table * Add data and storage services to Kibana context, rename useCore to useStartServices and replace usage of useStartDeps * Initial attempt at adding query bar for log stream * Adjust app layout to allow page content to be full height * Dataset and log level filters, split into smaller files * Use data plugin's `QueryStringInput` component for query bar * Add open in Logs UI link * Clean up unused storage dependency * Remove agent activity log and related dead code * Clean up i18n * Clean up plugin deps, fix routing * Add back storage dependency that data plugin components need * Remove dependency on infra for logs UI link * Change default date range to last one day * Adjust panel padding * Add comment * Move module declarations to top-level x-pack/typings * Fix missed renaming * Remove unused path * Move building of log stream query into separate service with unit tests * Adjust test conditions
1 parent 6164d04 commit a8913d3

File tree

60 files changed

+788
-914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+788
-914
lines changed

x-pack/plugins/fleet/kibana.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"requiredPlugins": ["licensing", "data", "encryptedSavedObjects"],
88
"optionalPlugins": ["security", "features", "cloud", "usageCollection", "home"],
99
"extraPublicDirs": ["common"],
10-
"requiredBundles": ["kibanaReact", "esUiShared", "home"]
10+
"requiredBundles": ["kibanaReact", "esUiShared", "home", "infra", "kibanaUtils"]
1111
}

x-pack/plugins/fleet/public/applications/fleet/components/search_bar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IFieldType } from 'src/plugins/data/public';
99
// @ts-ignore
1010
import { EuiSuggest, EuiSuggestItemProps } from '@elastic/eui';
1111
import { i18n } from '@kbn/i18n';
12-
import { useDebounce, useStartDeps } from '../hooks';
12+
import { useDebounce, useStartServices } from '../hooks';
1313
import { INDEX_NAME, AGENT_SAVED_OBJECT_TYPE } from '../constants';
1414

1515
const DEBOUNCE_SEARCH_MS = 150;
@@ -80,7 +80,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
8080
);
8181
};
8282

83-
function transformSuggestionType(type: string): { iconType: string; color: string } {
83+
export function transformSuggestionType(type: string): { iconType: string; color: string } {
8484
switch (type) {
8585
case 'field':
8686
return { iconType: 'kqlField', color: 'tint4' };
@@ -96,7 +96,7 @@ function transformSuggestionType(type: string): { iconType: string; color: strin
9696
}
9797

9898
function useSuggestions(fieldPrefix: string, search: string) {
99-
const { data } = useStartDeps();
99+
const { data } = useStartServices();
100100

101101
const debouncedSearch = useDebounce(search, DEBOUNCE_SEARCH_MS);
102102
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);

x-pack/plugins/fleet/public/applications/fleet/components/settings_flyout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ import {
2525
import { FormattedMessage } from '@kbn/i18n/react';
2626
import { EuiText } from '@elastic/eui';
2727
import { safeLoad } from 'js-yaml';
28-
import { useComboInput, useCore, useGetSettings, useInput, sendPutSettings } from '../hooks';
28+
import {
29+
useComboInput,
30+
useStartServices,
31+
useGetSettings,
32+
useInput,
33+
sendPutSettings,
34+
} from '../hooks';
2935
import { useGetOutputs, sendPutOutput } from '../hooks/use_request/outputs';
3036
import { isDiffPathProtocol } from '../../../../common/';
3137

@@ -37,7 +43,7 @@ interface Props {
3743

3844
function useSettingsForm(outputId: string | undefined, onSuccess: () => void) {
3945
const [isLoading, setIsloading] = React.useState(false);
40-
const { notifications } = useCore();
46+
const { notifications } = useStartServices();
4147
const kibanaUrlsInput = useComboInput([], (value) => {
4248
if (value.length === 0) {
4349
return [

x-pack/plugins/fleet/public/applications/fleet/constants/page_paths.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ export const PAGE_ROUTING_PATHS = {
5151
fleet: '/fleet',
5252
fleet_agent_list: '/fleet/agents',
5353
fleet_agent_details: '/fleet/agents/:agentId/:tabId?',
54-
fleet_agent_details_events: '/fleet/agents/:agentId',
55-
fleet_agent_details_details: '/fleet/agents/:agentId/details',
54+
fleet_agent_details_logs: '/fleet/agents/:agentId/logs',
5655
fleet_enrollment_tokens: '/fleet/enrollment-tokens',
5756
data_streams: '/data-streams',
5857
};

x-pack/plugins/fleet/public/applications/fleet/hooks/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
*/
66

77
export { useCapabilities } from './use_capabilities';
8-
export { useCore } from './use_core';
8+
export { useStartServices } from './use_core';
99
export { useConfig, ConfigContext } from './use_config';
1010
export { useKibanaVersion, KibanaVersionContext } from './use_kibana_version';
11-
export { useSetupDeps, useStartDeps, DepsContext } from './use_deps';
1211
export { licenseService, useLicense } from './use_license';
1312
export { useBreadcrumbs } from './use_breadcrumbs';
1413
export { useLink } from './use_link';

x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { i18n } from '@kbn/i18n';
77
import { ChromeBreadcrumb } from 'src/core/public';
88
import { BASE_PATH, Page, DynamicPagePathValues, pagePathGetters } from '../constants';
9-
import { useCore } from './use_core';
9+
import { useStartServices } from './use_core';
1010

1111
const BASE_BREADCRUMB: ChromeBreadcrumb = {
1212
href: pagePathGetters.overview(),
@@ -204,7 +204,7 @@ const breadcrumbGetters: {
204204
};
205205

206206
export function useBreadcrumbs(page: Page, values: DynamicPagePathValues = {}) {
207-
const { chrome, http } = useCore();
207+
const { chrome, http } = useStartServices();
208208
const breadcrumbs: ChromeBreadcrumb[] = breadcrumbGetters[page](values).map((breadcrumb) => ({
209209
...breadcrumb,
210210
href: breadcrumb.href ? http.basePath.prepend(`${BASE_PATH}#${breadcrumb.href}`) : undefined,

x-pack/plugins/fleet/public/applications/fleet/hooks/use_capabilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { useCore } from './';
7+
import { useStartServices } from './';
88

99
export function useCapabilities() {
10-
const core = useCore();
10+
const core = useStartServices();
1111
return core.application.capabilities.fleet;
1212
}

x-pack/plugins/fleet/public/applications/fleet/hooks/use_core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { CoreStart } from 'kibana/public';
7+
import { FleetStartServices } from '../../../plugin';
88
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
99

10-
export function useCore(): CoreStart {
11-
const { services } = useKibana<CoreStart>();
10+
export function useStartServices(): FleetStartServices {
11+
const { services } = useKibana<FleetStartServices>();
1212
if (services === null) {
1313
throw new Error('KibanaContextProvider not initialized');
1414
}

x-pack/plugins/fleet/public/applications/fleet/hooks/use_deps.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

x-pack/plugins/fleet/public/applications/fleet/hooks/use_kibana_link.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { useCore } from './';
7+
import { useStartServices } from './';
88

99
const KIBANA_BASE_PATH = '/app/kibana';
1010

1111
export function useKibanaLink(path: string = '/') {
12-
const core = useCore();
12+
const core = useStartServices();
1313
return core.http.basePath.prepend(`${KIBANA_BASE_PATH}#${path}`);
1414
}

0 commit comments

Comments
 (0)