Skip to content

Commit

Permalink
Merge branch 'main' into oas/remove-elastic-api-from-stateful-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens authored Oct 29, 2024
2 parents b6dd030 + 88ebb55 commit dca423d
Show file tree
Hide file tree
Showing 24 changed files with 310 additions and 59 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@
"@langchain/langgraph": "0.0.34",
"@langchain/openai": "^0.1.3",
"@langtrase/trace-attributes": "^3.0.8",
"@launchdarkly/node-server-sdk": "^9.6.0",
"@launchdarkly/node-server-sdk": "^9.6.1",
"@launchdarkly/openfeature-node-server": "^1.0.0",
"@loaders.gl/core": "^3.4.7",
"@loaders.gl/json": "^3.4.7",
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-test/src/jest/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ module.exports = (request, options) => {
});
}

if (request === '@launchdarkly/js-sdk-common') {
return resolve.sync('@launchdarkly/js-sdk-common/dist/cjs/index.cjs', {
basedir: options.basedir,
extensions: options.extensions,
});
}

if (request === `elastic-apm-node`) {
return APM_AGENT_MOCK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function runDockerGenerator(
*/
if (flags.baseImage === 'wolfi')
baseImageName =
'docker.elastic.co/wolfi/chainguard-base:latest@sha256:de4d5b06ee2074eb716f29e72b170346fd4715e5f083fc83a378603ce5bd9ced';
'docker.elastic.co/wolfi/chainguard-base:latest@sha256:18153942f0d6e97bc6131cd557c7ed3be6e892846a5df0760896eb8d15b1b236';

let imageFlavor = '';
if (flags.baseImage === 'ubi') imageFlavor += `-ubi`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ export const useNavigateFindings = () => {

export const useNavigateVulnerabilities = () =>
useNavigate(findingsNavigation.vulnerabilities.path);

export const useNavigateNativeVulnerabilities = () => {
const navToVulnerabilities = useNavigateVulnerabilities();

return useCallback(
(filterParams: NavFilter = {}, groupBy?: string[]) => {
navToVulnerabilities(
{ ...filterParams, 'data_stream.dataset': 'cloud_security_posture.vulnerabilities' },
groupBy
);
},
[navToVulnerabilities]
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import React, { useMemo } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiHealth } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { VULNERABILITIES_SEVERITY } from '@kbn/cloud-security-posture-common';
import { getSeverityStatusColor } from '@kbn/cloud-security-posture';
import { VulnCounterCard, type VulnCounterCardProps } from '../../components/vuln_counter_card';
import { useVulnerabilityDashboardApi } from '../../common/api/use_vulnerability_dashboard_api';
import { CompactFormattedNumber } from '../../components/compact_formatted_number';

export const VulnerabilityStatistics = () => {
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();
const getVulnerabilityDashboard = useVulnerabilityDashboardApi();

const stats: VulnCounterCardProps[] = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { NavFilter } from '@kbn/cloud-security-posture/src/utils/query_utils';
import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
import { CVSScoreBadge, SeverityStatusBadge } from '@kbn/cloud-security-posture';
import {
Expand All @@ -33,7 +33,7 @@ import { VULNERABILITY_GROUPING_OPTIONS, VULNERABILITY_FIELDS } from '../../comm
export const VulnerabilityTablePanelSection = () => {
const getVulnerabilityDashboard = useVulnerabilityDashboardApi();
const { euiTheme } = useEuiTheme();
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();

const onCellClick = useCallback(
(filters: NavFilter) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { EuiButton, EuiComboBox } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';

import { useNavigateVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import { useNavigateNativeVulnerabilities } from '@kbn/cloud-security-posture/src/hooks/use_navigate_findings';
import type { VulnSeverity } from '@kbn/cloud-security-posture-common';
import { VULNERABILITIES_SEVERITY } from '@kbn/cloud-security-posture-common';
import { getSeverityStatusColor } from '@kbn/cloud-security-posture';
Expand Down Expand Up @@ -50,7 +50,7 @@ const theme: PartialTheme = {
};

const ViewAllButton = () => {
const navToVulnerabilities = useNavigateVulnerabilities();
const navToVulnerabilities = useNavigateNativeVulnerabilities();

return (
<EuiButton onClick={() => navToVulnerabilities()} size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export enum TelemetryEventTypes {
EntityDetailsClicked = 'Entity Details Clicked',
EntityAlertsClicked = 'Entity Alerts Clicked',
EntityRiskFiltered = 'Entity Risk Filtered',
EntityStoreEnablementToggleClicked = 'Entity Store Enablement Toggle Clicked',
EntityStoreDashboardInitButtonClicked = 'Entity Store Initialization Button Clicked',
MLJobUpdate = 'ML Job Update',
AddRiskInputToTimelineClicked = 'Add Risk Input To Timeline Clicked',
ToggleRiskSummaryClicked = 'Toggle Risk Summary Clicked',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,36 @@ export const assetCriticalityCsvImportedEvent: TelemetryEvent = {
},
},
};

export const entityStoreInitEvent: TelemetryEvent = {
eventType: TelemetryEventTypes.EntityStoreDashboardInitButtonClicked,
schema: {
timestamp: {
type: 'date',
_meta: {
description: 'Timestamp of the event',
optional: false,
},
},
},
};

export const entityStoreEnablementEvent: TelemetryEvent = {
eventType: TelemetryEventTypes.EntityStoreEnablementToggleClicked,
schema: {
timestamp: {
type: 'date',
_meta: {
description: 'Timestamp of the event',
optional: false,
},
},
action: {
type: 'keyword',
_meta: {
description: 'Event toggle action',
optional: false,
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export interface ReportAssetCriticalityCsvImportedParams {
};
}

export interface ReportEntityStoreEnablementParams {
timestamp: string;
action: 'start' | 'stop';
}

export interface ReportEntityStoreInitParams {
timestamp: string;
}

export type ReportEntityAnalyticsTelemetryEventParams =
| ReportEntityDetailsClickedParams
| ReportEntityAlertsClickedParams
Expand All @@ -68,7 +77,9 @@ export type ReportEntityAnalyticsTelemetryEventParams =
| ReportAddRiskInputToTimelineClickedParams
| ReportAssetCriticalityCsvPreviewGeneratedParams
| ReportAssetCriticalityFileSelectedParams
| ReportAssetCriticalityCsvImportedParams;
| ReportAssetCriticalityCsvImportedParams
| ReportEntityStoreEnablementParams
| ReportEntityStoreInitParams;

export type EntityAnalyticsTelemetryEvent =
| {
Expand Down Expand Up @@ -106,4 +117,12 @@ export type EntityAnalyticsTelemetryEvent =
| {
eventType: TelemetryEventTypes.AssetCriticalityCsvImported;
schema: RootSchema<ReportAssetCriticalityCsvImportedParams>;
}
| {
eventType: TelemetryEventTypes.EntityStoreEnablementToggleClicked;
schema: RootSchema<ReportEntityStoreEnablementParams>;
}
| {
eventType: TelemetryEventTypes.EntityStoreDashboardInitButtonClicked;
schema: RootSchema<ReportEntityStoreInitParams>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
assetCriticalityCsvPreviewGeneratedEvent,
assetCriticalityFileSelectedEvent,
assetCriticalityCsvImportedEvent,
entityStoreEnablementEvent,
entityStoreInitEvent,
} from './entity_analytics';
import {
assistantInvokedEvent,
Expand Down Expand Up @@ -172,6 +174,8 @@ export const telemetryEvents = [
assetCriticalityCsvPreviewGeneratedEvent,
assetCriticalityFileSelectedEvent,
assetCriticalityCsvImportedEvent,
entityStoreEnablementEvent,
entityStoreInitEvent,
toggleRiskSummaryClickedEvent,
RiskInputsExpandedFlyoutOpenedEvent,
addRiskInputToTimelineClickedEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ export const createTelemetryClientMock = (): jest.Mocked<TelemetryClientStart> =
reportOpenNoteInExpandableFlyoutClicked: jest.fn(),
reportAddNoteFromExpandableFlyoutClicked: jest.fn(),
reportPreviewRule: jest.fn(),
reportEntityStoreEnablement: jest.fn(),
reportEntityStoreInit: jest.fn(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import type {
ReportEventLogShowSourceEventDateRangeParams,
ReportEventLogFilterByRunTypeParams,
PreviewRuleParams,
ReportEntityStoreEnablementParams,
ReportEntityStoreInitParams,
} from './types';
import { TelemetryEventTypes } from './constants';

Expand Down Expand Up @@ -216,4 +218,12 @@ export class TelemetryClient implements TelemetryClientStart {
public reportPreviewRule = (params: PreviewRuleParams) => {
this.analytics.reportEvent(TelemetryEventTypes.PreviewRule, params);
};

public reportEntityStoreEnablement = (params: ReportEntityStoreEnablementParams) => {
this.analytics.reportEvent(TelemetryEventTypes.EntityStoreEnablementToggleClicked, params);
};

public reportEntityStoreInit = (params: ReportEntityStoreInitParams) => {
this.analytics.reportEvent(TelemetryEventTypes.EntityStoreDashboardInitButtonClicked, params);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import type {
ReportAssetCriticalityCsvPreviewGeneratedParams,
ReportAssetCriticalityFileSelectedParams,
ReportAssetCriticalityCsvImportedParams,
ReportEntityStoreEnablementParams,
ReportEntityStoreInitParams,
} from './events/entity_analytics/types';
import type {
AssistantTelemetryEvent,
Expand Down Expand Up @@ -78,17 +80,7 @@ export * from './events/ai_assistant/types';
export * from './events/alerts_grouping/types';
export * from './events/data_quality/types';
export * from './events/onboarding/types';
export type {
ReportEntityAlertsClickedParams,
ReportEntityDetailsClickedParams,
ReportEntityRiskFilteredParams,
ReportRiskInputsExpandedFlyoutOpenedParams,
ReportToggleRiskSummaryClickedParams,
ReportAddRiskInputToTimelineClickedParams,
ReportAssetCriticalityCsvPreviewGeneratedParams,
ReportAssetCriticalityFileSelectedParams,
ReportAssetCriticalityCsvImportedParams,
} from './events/entity_analytics/types';
export * from './events/entity_analytics/types';
export * from './events/document_details/types';
export * from './events/manual_rule_run/types';
export * from './events/event_log/types';
Expand Down Expand Up @@ -168,6 +160,9 @@ export interface TelemetryClientStart {
): void;
reportAssetCriticalityCsvImported(params: ReportAssetCriticalityCsvImportedParams): void;
reportCellActionClicked(params: ReportCellActionClickedParams): void;
// Entity Analytics Entity Store
reportEntityStoreEnablement(params: ReportEntityStoreEnablementParams): void;
reportEntityStoreInit(params: ReportEntityStoreInitParams): void;

reportAnomaliesCountClicked(params: ReportAnomaliesCountClickedParams): void;
reportDataQualityIndexChecked(params: ReportDataQualityIndexCheckedParams): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { UseMutationOptions } from '@tanstack/react-query';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useCallback, useState } from 'react';

import { useKibana } from '../../../../common/lib/kibana/kibana_react';
import type {
DeleteEntityEngineResponse,
InitEntityEngineResponse,
Expand All @@ -21,6 +22,7 @@ const ENTITY_STORE_ENABLEMENT_INIT = 'ENTITY_STORE_ENABLEMENT_INIT';

export const useEntityStoreEnablement = () => {
const [polling, setPolling] = useState(false);
const { telemetry } = useKibana().services;

useEntityEngineStatus({
disabled: !polling,
Expand All @@ -46,8 +48,11 @@ export const useEntityStoreEnablement = () => {
});

const enable = useCallback(() => {
telemetry?.reportEntityStoreInit({
timestamp: new Date().toISOString(),
});
initialize().then(() => setPolling(true));
}, [initialize]);
}, [initialize, telemetry]);

return { enable };
};
Expand All @@ -65,10 +70,17 @@ export const useInvalidateEntityEngineStatusQuery = () => {
};

export const useInitEntityEngineMutation = (options?: UseMutationOptions<{}>) => {
const { telemetry } = useKibana().services;
const invalidateEntityEngineStatusQuery = useInvalidateEntityEngineStatusQuery();
const { initEntityStore } = useEntityStoreRoutes();
return useMutation<InitEntityEngineResponse[]>(
() => Promise.all([initEntityStore('user'), initEntityStore('host')]),
() => {
telemetry?.reportEntityStoreEnablement({
timestamp: new Date().toISOString(),
action: 'start',
});
return Promise.all([initEntityStore('user'), initEntityStore('host')]);
},
{
...options,
mutationKey: INIT_ENTITY_ENGINE_STATUS_KEY,
Expand All @@ -86,10 +98,17 @@ export const useInitEntityEngineMutation = (options?: UseMutationOptions<{}>) =>
export const STOP_ENTITY_ENGINE_STATUS_KEY = ['POST', 'STOP_ENTITY_ENGINE'];

export const useStopEntityEngineMutation = (options?: UseMutationOptions<{}>) => {
const { telemetry } = useKibana().services;
const invalidateEntityEngineStatusQuery = useInvalidateEntityEngineStatusQuery();
const { stopEntityStore } = useEntityStoreRoutes();
return useMutation<StopEntityEngineResponse[]>(
() => Promise.all([stopEntityStore('user'), stopEntityStore('host')]),
() => {
telemetry?.reportEntityStoreEnablement({
timestamp: new Date().toISOString(),
action: 'stop',
});
return Promise.all([stopEntityStore('user'), stopEntityStore('host')]);
},
{
...options,
mutationKey: STOP_ENTITY_ENGINE_STATUS_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const loginWithoutAccess = (url: string) => {
loadPage(url);
};

// Failing: See https://github.com/elastic/kibana/issues/191914
describe.skip('Artifacts pages', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'] }, () => {
describe('Artifacts pages', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'] }, () => {
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;

before(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('Event Filters', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'
removeAllArtifacts();
});

// FLAKY: https://github.com/elastic/kibana/issues/194135
describe.skip('when editing event filter value', () => {
describe('when editing event filter value', () => {
let eventFiltersMock: ArtifactsFixtureType;
beforeEach(() => {
login();
Expand Down
Loading

0 comments on commit dca423d

Please sign in to comment.