Skip to content

Commit

Permalink
Merge branch 'main' into 157484-integrate-SLO-apm
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio committed Jun 20, 2023
2 parents d80152b + 66e87e6 commit 0890e04
Show file tree
Hide file tree
Showing 41 changed files with 802 additions and 483 deletions.
3 changes: 0 additions & 3 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Expand Up @@ -1898,9 +1898,6 @@
"fleet-uninstall-tokens": {
"dynamic": false,
"properties": {
"created_at": {
"type": "date"
},
"policy_id": {
"type": "keyword"
},
Expand Down
Expand Up @@ -96,7 +96,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f",
"fleet-preconfiguration-deletion-record": "c52ea1e13c919afe8a5e8e3adbb7080980ecc08e",
"fleet-proxy": "6cb688f0d2dd856400c1dbc998b28704ff70363d",
"fleet-uninstall-tokens": "d25a8aedb522d2b839ab0950160777528122070f",
"fleet-uninstall-tokens": "ed8aa37e3cdd69e4360709e64944bb81cae0c025",
"graph-workspace": "5cc6bb1455b078fd848c37324672163f09b5e376",
"guided-onboarding-guide-state": "d338972ed887ac480c09a1a7fbf582d6a3827c91",
"guided-onboarding-plugin-state": "bc109e5ef46ca594fdc179eda15f3095ca0a37a4",
Expand Down
3 changes: 3 additions & 0 deletions x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts
Expand Up @@ -22,6 +22,7 @@ import {
summarySchema,
tagsSchema,
timeWindowSchema,
timeWindowTypeSchema,
} from '../schema';

const createSLOParamsSchema = t.type({
Expand Down Expand Up @@ -166,6 +167,7 @@ type GetPreviewDataParams = t.TypeOf<typeof getPreviewDataParamsSchema.props.bod
type GetPreviewDataResponse = t.TypeOf<typeof getPreviewDataResponseSchema>;

type BudgetingMethod = t.TypeOf<typeof budgetingMethodSchema>;
type TimeWindow = t.TypeOf<typeof timeWindowTypeSchema>;

type Indicator = t.OutputOf<typeof indicatorSchema>;
type MetricCustomIndicator = t.OutputOf<typeof metricCustomIndicatorSchema>;
Expand Down Expand Up @@ -211,4 +213,5 @@ export type {
Indicator,
MetricCustomIndicator,
KQLCustomIndicator,
TimeWindow,
};
5 changes: 5 additions & 0 deletions x-pack/packages/kbn-slo-schema/src/schema/time_window.ts
Expand Up @@ -20,6 +20,10 @@ const calendarAlignedTimeWindowSchema = t.type({
type: calendarAlignedTimeWindowTypeSchema,
});

const timeWindowTypeSchema = t.union([
rollingTimeWindowTypeSchema,
calendarAlignedTimeWindowTypeSchema,
]);
const timeWindowSchema = t.union([rollingTimeWindowSchema, calendarAlignedTimeWindowSchema]);

export {
Expand All @@ -28,4 +32,5 @@ export {
calendarAlignedTimeWindowSchema,
calendarAlignedTimeWindowTypeSchema,
timeWindowSchema,
timeWindowTypeSchema,
};
1 change: 0 additions & 1 deletion x-pack/plugins/fleet/server/saved_objects/index.ts
Expand Up @@ -410,7 +410,6 @@ const getSavedObjectTypes = (): { [key: string]: SavedObjectsType } => ({
mappings: {
dynamic: false,
properties: {
created_at: { type: 'date' },
policy_id: { type: 'keyword' },
token_plain: { type: 'keyword' },
},
Expand Down
Expand Up @@ -152,7 +152,7 @@ export class UninstallTokenService implements UninstallTokenServiceInterface {
latest: {
top_hits: {
size: 1,
sort: [{ [`${UNINSTALL_TOKENS_SAVED_OBJECT_TYPE}.created_at`]: { order: 'desc' } }],
sort: [{ created_at: { order: 'desc' } }],
},
},
},
Expand Down
Expand Up @@ -8,15 +8,17 @@ import React from 'react';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { EuiButtonEmpty } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { LogViewReference } from '../../../../../../../common/log_views';
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana';

interface LogsLinkToStreamProps {
startTime: number;
endTime: number;
query: string;
logView: LogViewReference;
}

export const LogsLinkToStream = ({ startTime, endTime, query }: LogsLinkToStreamProps) => {
export const LogsLinkToStream = ({ startTime, endTime, query, logView }: LogsLinkToStreamProps) => {
const { services } = useKibanaContextForPlugin();
const { locators } = services;

Expand All @@ -30,6 +32,7 @@ export const LogsLinkToStream = ({ startTime, endTime, query }: LogsLinkToStream
endTime,
},
filter: query,
logView,
})}
data-test-subj="hostsView-logs-link-to-stream-button"
iconType="popout"
Expand Down
Expand Up @@ -5,9 +5,15 @@
* 2.0.
*/

import React, { useMemo } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { DEFAULT_LOG_VIEW } from '../../../../../../../common/log_views';
import type {
LogIndexReference,
LogViewReference,
} from '../../../../../../../common/log_views/types';
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana';
import { InfraLoadingPanel } from '../../../../../../components/loading';
import { LogStream } from '../../../../../../components/log_stream';
import { useHostsViewContext } from '../../../hooks/use_hosts_view';
Expand All @@ -23,11 +29,57 @@ export const LogsTabContent = () => {
const { from, to } = useMemo(() => getDateRangeAsTimestamp(), [getDateRangeAsTimestamp]);
const { hostNodes, loading } = useHostsViewContext();

const [logViewIndices, setLogViewIndices] = useState<LogIndexReference>();

const {
services: {
logViews: { client },
},
} = useKibanaContextForPlugin();

useEffect(() => {
const getLogView = async () => {
const { attributes } = await client.getLogView(DEFAULT_LOG_VIEW);
setLogViewIndices(attributes.logIndices);
};
getLogView();
}, [client, setLogViewIndices]);

const hostsFilterQuery = useMemo(
() => createHostsFilter(hostNodes.map((p) => p.name)),
[hostNodes]
);

const logView: LogViewReference = useMemo(() => {
return {
type: 'log-view-inline',
id: 'hosts-logs-view',
attributes: {
name: 'Hosts Logs View',
description: 'Default view for hosts logs tab',
logIndices: logViewIndices!,
logColumns: [
{
timestampColumn: {
id: '5e7f964a-be8a-40d8-88d2-fbcfbdca0e2f',
},
},
{
fieldColumn: {
id: 'eb9777a8-fcd3-420e-ba7d-172fff6da7a2',
field: 'host.name',
},
},
{
messageColumn: {
id: 'b645d6da-824b-4723-9a2a-e8cece1645c0',
},
},
],
},
};
}, [logViewIndices]);

const logsLinkToStreamQuery = useMemo(() => {
const hostsFilterQueryParam = createHostsFilterQueryParam(hostNodes.map((p) => p.name));

Expand All @@ -38,7 +90,7 @@ export const LogsTabContent = () => {
return filterQuery.query || hostsFilterQueryParam;
}, [filterQuery.query, hostNodes]);

if (loading) {
if (loading || !logViewIndices) {
return (
<EuiFlexGroup style={{ height: 300 }} direction="column" alignItems="stretch">
<EuiFlexItem grow>
Expand All @@ -64,14 +116,19 @@ export const LogsTabContent = () => {
<LogsSearchBar />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<LogsLinkToStream startTime={from} endTime={to} query={logsLinkToStreamQuery} />
<LogsLinkToStream
startTime={from}
endTime={to}
query={logsLinkToStreamQuery}
logView={logView}
/>
</EuiFlexItem>
</EuiFlexGroup>

<EuiFlexItem>
<LogStream
height={500}
logView={{ type: 'log-view-reference', logViewId: 'default' }}
logView={logView}
startTimestamp={from}
endTimestamp={to}
filters={[hostsFilterQuery]}
Expand Down
19 changes: 17 additions & 2 deletions x-pack/plugins/infra/public/pages/metrics/hosts/index.tsx
Expand Up @@ -12,6 +12,7 @@ import { APP_WRAPPER_CLASS } from '@kbn/core/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { i18n } from '@kbn/i18n';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { SourceErrorPage } from '../../../components/source_error_page';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import { useSourceContext } from '../../../containers/metrics_source';
Expand All @@ -25,10 +26,24 @@ import { HostContainer } from './components/hosts_container';
import { BetaBadge } from '../../../components/beta_badge';
import { NoRemoteCluster } from '../../../components/empty_states';

const HOSTS_FEEDBACK_LINK = 'https://ela.st/host-feedback';
const HOSTS_FEEDBACK_LINK =
'https://docs.google.com/forms/d/e/1FAIpQLScRHG8TIVb1Oq8ZhD4aks3P1TmgiM58TY123QpDCcBz83YC6w/viewform';
const KIBANA_VERSION_QUERY_PARAM = 'entry.548460210';

const getHostFeedbackURL = (kibanaVersion?: string) => {
const url = new URL(HOSTS_FEEDBACK_LINK);
if (kibanaVersion) {
url.searchParams.append(KIBANA_VERSION_QUERY_PARAM, kibanaVersion);
}

return url.href;
};

export const HostsPage = () => {
const { isLoading, loadSourceFailureMessage, loadSource, source } = useSourceContext();
const {
services: { kibanaVersion },
} = useKibanaContextForPlugin();

useTrackPageview({ app: 'infra_metrics', path: 'hosts' });
useTrackPageview({ app: 'infra_metrics', path: 'hosts', delay: 15000 });
Expand Down Expand Up @@ -83,7 +98,7 @@ export const HostsPage = () => {
rightSideItems: [
<EuiButton
data-test-subj="infraHostsPageTellUsWhatYouThinkButton"
href={HOSTS_FEEDBACK_LINK}
href={getHostFeedbackURL(kibanaVersion)}
target="_blank"
color="warning"
iconType="editorComment"
Expand Down
11 changes: 9 additions & 2 deletions x-pack/plugins/infra/public/plugin.ts
Expand Up @@ -61,6 +61,7 @@ export class Plugin implements InfraClientPluginClass {
private telemetry: TelemetryService;
private locators?: InfraLocators;
private appTarget: string;
private kibanaVersion: string;
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));

constructor(context: PluginInitializerContext<InfraPublicConfig>) {
Expand All @@ -74,6 +75,7 @@ export class Plugin implements InfraClientPluginClass {
this.metricsExplorerViews = new MetricsExplorerViewsService();
this.telemetry = new TelemetryService();
this.appTarget = this.config.logs.app_target;
this.kibanaVersion = context.env.packageInfo.version;
}

setup(core: InfraClientCoreSetup, pluginsSetup: InfraClientSetupDeps) {
Expand Down Expand Up @@ -286,10 +288,15 @@ export class Plugin implements InfraClientPluginClass {
deepLinks: infraDeepLinks,
mount: async (params: AppMountParameters) => {
// mount callback should not use setup dependencies, get start dependencies instead
const [coreStart, pluginsStart, pluginStart] = await core.getStartServices();
const [coreStart, plugins, pluginStart] = await core.getStartServices();
const { renderApp } = await import('./apps/metrics_app');

return renderApp(coreStart, pluginsStart, pluginStart, params);
return renderApp(
coreStart,
{ ...plugins, kibanaVersion: this.kibanaVersion },
pluginStart,
params
);
},
});

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/infra/public/types.ts
Expand Up @@ -93,6 +93,7 @@ export interface InfraClientStartDeps {
dataViews: DataViewsPublicPluginStart;
discover: DiscoverStart;
embeddable?: EmbeddableStart;
kibanaVersion?: string;
lens: LensPublicStart;
ml: MlPluginStart;
observability: ObservabilityPublicStart;
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/ml/common/types/storage.ts
Expand Up @@ -14,6 +14,7 @@ export const ML_GETTING_STARTED_CALLOUT_DISMISSED = 'ml.gettingStarted.isDismiss
export const ML_FROZEN_TIER_PREFERENCE = 'ml.frozenDataTierPreference';
export const ML_ANOMALY_EXPLORER_PANELS = 'ml.anomalyExplorerPanels';
export const ML_NOTIFICATIONS_LAST_CHECKED_AT = 'ml.notificationsLastCheckedAt';
export const ML_OVERVIEW_PANELS = 'ml.overviewPanels';

export type PartitionFieldConfig =
| {
Expand Down Expand Up @@ -52,6 +53,12 @@ export interface AnomalyExplorerPanelsState {
mainPage: { size: number };
}

export interface OverviewPanelsState {
nodes: boolean;
adJobs: boolean;
dfaJobs: boolean;
}

export interface MlStorageRecord {
[key: string]: unknown;
[ML_ENTITY_FIELDS_CONFIG]: PartitionFieldsConfig;
Expand All @@ -60,6 +67,7 @@ export interface MlStorageRecord {
[ML_FROZEN_TIER_PREFERENCE]: FrozenTierPreference;
[ML_ANOMALY_EXPLORER_PANELS]: AnomalyExplorerPanelsState | undefined;
[ML_NOTIFICATIONS_LAST_CHECKED_AT]: number | undefined;
[ML_OVERVIEW_PANELS]: OverviewPanelsState;
}

export type MlStorage = Partial<MlStorageRecord> | null;
Expand All @@ -78,6 +86,8 @@ export type TMlStorageMapped<T extends MlStorageKey> = T extends typeof ML_ENTIT
? AnomalyExplorerPanelsState | undefined
: T extends typeof ML_NOTIFICATIONS_LAST_CHECKED_AT
? number | undefined
: T extends typeof ML_OVERVIEW_PANELS
? OverviewPanelsState | undefined
: null;

export const ML_STORAGE_KEYS = [
Expand All @@ -87,4 +97,5 @@ export const ML_STORAGE_KEYS = [
ML_FROZEN_TIER_PREFERENCE,
ML_ANOMALY_EXPLORER_PANELS,
ML_NOTIFICATIONS_LAST_CHECKED_AT,
ML_OVERVIEW_PANELS,
] as const;

0 comments on commit 0890e04

Please sign in to comment.