Skip to content

Commit

Permalink
Merge branch 'main' into 176425-adjust-es_archive-mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 23, 2024
2 parents a549ecc + 87e2f03 commit fede946
Show file tree
Hide file tree
Showing 19 changed files with 496 additions and 188 deletions.
4 changes: 4 additions & 0 deletions docs/management/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ a| <<cases-action-type,Cases>>

| Add alerts to cases.

a| <<crowdstrike-action-type,CrowdStrike>>

| Send a request to CrowdStrike.

a| <<d3security-action-type,D3 Security>>

| Send a request to D3 Security.
Expand Down
40 changes: 40 additions & 0 deletions docs/management/connectors/action-types/crowdstrike.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[[crowdstrike-action-type]]
== CrowdStrike connector
++++
<titleabbrev>CrowdStrike</titleabbrev>
++++
:frontmatter-description: Add a connector that can use the CrowdStrike API to send actions.
:frontmatter-tags-products: [kibana]
:frontmatter-tags-content-type: [how-to]
:frontmatter-tags-user-goals: [configure]

preview::[]

The CrowdStrike connector communicates with CrowdStrike Management Console via REST API.

[float]
[[define-crowdstrike-ui]]
=== Create connectors in {kib}

You can create connectors in *{stack-manage-app} > {connectors-ui}*. For example:

[role="screenshot"]
image::management/connectors/images/crowdstrike-connector.png[Crowdstrike connector]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
[[crowdstrike-connector-configuration]]
==== Connector configuration

CrowdStrike connectors have the following configuration properties:

CrowdStrike API URL:: The CrowdStrike tenant URL. If you are using the <<action-settings,`xpack.actions.allowedHosts`>> setting, make sure the hostname is added to the allowed hosts.
CrowdStrike Client ID:: A CrowdStrike API client ID.
Client Secret:: A CrowdStrike API client secret created by the user.


[float]
[[crowdstrike-action-parameters]]
=== Test connectors

At this time, you cannot test the CrowdStrike connector.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/management/connectors/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include::action-types/bedrock.asciidoc[leveloffset=+1]
include::action-types/cases-action-type.asciidoc[leveloffset=+1]
include::action-types/crowdstrike.asciidoc[leveloffset=+1]
include::action-types/d3security.asciidoc[leveloffset=+1]
include::action-types/email.asciidoc[leveloffset=+1]
include::action-types/gemini.asciidoc[leveloffset=+1]
Expand Down
36 changes: 31 additions & 5 deletions packages/kbn-search-connectors/types/native_connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,10 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
defaultMessage: 'Github',
}),
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
[FeatureName.INCREMENTAL_SYNC]: {
enabled: true,
},
Expand Down Expand Up @@ -1400,6 +1404,10 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
},
},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
[FeatureName.DOCUMENT_LEVEL_SECURITY]: {
enabled: true,
},
Expand Down Expand Up @@ -2566,7 +2574,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: false },
advanced: { enabled: true },
basic: { enabled: true },
},
},
Expand Down Expand Up @@ -2868,7 +2876,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: false },
advanced: { enabled: true },
basic: { enabled: true },
},
[FeatureName.INCREMENTAL_SYNC]: {
Expand Down Expand Up @@ -2969,7 +2977,12 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
value: '',
},
},
features: {},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
},
name: i18n.translate('searchConnectors.nativeConnectors.notion.name', {
defaultMessage: 'Notion',
}),
Expand Down Expand Up @@ -3098,6 +3111,10 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
defaultMessage: 'OneDrive',
}),
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
[FeatureName.DOCUMENT_LEVEL_SECURITY]: {
enabled: true,
},
Expand Down Expand Up @@ -3864,7 +3881,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: false },
advanced: { enabled: true },
basic: { enabled: true },
},
},
Expand Down Expand Up @@ -4013,14 +4030,23 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
value: false,
},
},
features: {},
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
},
name: i18n.translate('searchConnectors.content.nativeConnectors.s3.name', {
defaultMessage: 'S3',
}),
serviceType: 's3',
},
salesforce: {
features: {
[FeatureName.SYNC_RULES]: {
advanced: { enabled: true },
basic: { enabled: true },
},
[FeatureName.INCREMENTAL_SYNC]: {
enabled: true,
},
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/common/types/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export interface TrainedModelDeploymentStatsResponse {
threads_per_allocation: number;
number_of_allocations: number;
}>;
reason?: string;
}

export interface AllocatedModel {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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 { getModelDeploymentState } from './get_model_state';
import { MODEL_STATE } from '@kbn/ml-trained-models-utils';
import type { ModelItem } from './models_list';

describe('getModelDeploymentState', () => {
it('returns STARTED if any deployment is in STARTED state', () => {
const model = {
stats: {
model_id: '.elser_model_2',
model_size_stats: {
model_size_bytes: 438123914,
required_native_memory_bytes: 2101346304,
},

deployment_stats: [
{
deployment_id: '.elser_model_2_01',
model_id: '.elser_model_2',
state: 'starting',
},
{
deployment_id: '.elser_model_2',
model_id: '.elser_model_2',
state: 'started',
allocation_status: {
allocation_count: 1,
target_allocation_count: 1,
state: 'fully_allocated',
},
},
],
},
} as unknown as ModelItem;
const result = getModelDeploymentState(model);
expect(result).toEqual(MODEL_STATE.STARTED);
});

it('returns MODEL_STATE.STARTING if any deployment is in STARTING state', () => {
const model = {
stats: {
model_id: '.elser_model_2',
model_size_stats: {
model_size_bytes: 438123914,
required_native_memory_bytes: 2101346304,
},

deployment_stats: [
{
deployment_id: '.elser_model_2',
model_id: '.elser_model_2',
state: 'stopping',
},
{
deployment_id: '.elser_model_2_01',
model_id: '.elser_model_2',
state: 'starting',
},
{
deployment_id: '.elser_model_2',
model_id: '.elser_model_2',
state: 'stopping',
},
],
},
} as unknown as ModelItem;
const result = getModelDeploymentState(model);
expect(result).toEqual(MODEL_STATE.STARTING);
});

it('returns MODEL_STATE.STOPPING if every deployment is in STOPPING state', () => {
const model = {
stats: {
model_id: '.elser_model_2',
model_size_stats: {
model_size_bytes: 438123914,
required_native_memory_bytes: 2101346304,
},

deployment_stats: [
{
deployment_id: '.elser_model_2',
model_id: '.elser_model_2',
state: 'stopping',
},
{
deployment_id: '.elser_model_2_01',
model_id: '.elser_model_2',
state: 'stopping',
},
],
},
} as unknown as ModelItem;
const result = getModelDeploymentState(model);
expect(result).toEqual(MODEL_STATE.STOPPING);
});

it('returns undefined for empty deployment stats', () => {
const model = {
stats: {
model_id: '.elser_model_2',
model_size_stats: {
model_size_bytes: 438123914,
required_native_memory_bytes: 2101346304,
},

deployment_stats: [],
},
} as unknown as ModelItem;
const result = getModelDeploymentState(model);
expect(result).toEqual(undefined);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,34 @@
* 2.0.
*/

import type { ModelState } from '@kbn/ml-trained-models-utils';
import { MODEL_STATE } from '@kbn/ml-trained-models-utils';
import { DEPLOYMENT_STATE, MODEL_STATE, type ModelState } from '@kbn/ml-trained-models-utils';
import type { EuiHealthProps } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { ModelItem } from './models_list';

/**
* Resolves result model state based on the state of each deployment.
*
* If at least one deployment is in the STARTED state, the model state is STARTED.
* Then if none of the deployments are in the STARTED state, but at least one is in the STARTING state, the model state is STARTING.
* If all deployments are in the STOPPING state, the model state is STOPPING.
*/
export const getModelDeploymentState = (model: ModelItem): ModelState | undefined => {
if (!model.stats?.deployment_stats?.length) return;

if (model.stats?.deployment_stats?.some((v) => v.state === DEPLOYMENT_STATE.STARTED)) {
return MODEL_STATE.STARTED;
}
if (model.stats?.deployment_stats?.some((v) => v.state === DEPLOYMENT_STATE.STARTING)) {
return MODEL_STATE.STARTING;
}
if (model.stats?.deployment_stats?.every((v) => v.state === DEPLOYMENT_STATE.STOPPING)) {
return MODEL_STATE.STOPPING;
}
};

export const getModelStateColor = (
state: ModelState
state: ModelState | undefined
): { color: EuiHealthProps['color']; name: string } | null => {
switch (state) {
case MODEL_STATE.DOWNLOADED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { isDefined } from '@kbn/ml-is-defined';
import { useStorage } from '@kbn/ml-local-storage';
import { dynamic } from '@kbn/shared-ux-utility';
import useMountedState from 'react-use/lib/useMountedState';
import { getModelStateColor } from './get_model_state_color';
import { getModelStateColor, getModelDeploymentState } from './get_model_state';
import { ML_ELSER_CALLOUT_DISMISSED } from '../../../common/types/storage';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';
import { useModelActions } from './model_actions';
Expand Down Expand Up @@ -88,7 +88,11 @@ export type ModelItem = TrainedModelConfigResponse & {
origin_job_exists?: boolean;
deployment_ids: string[];
putModelConfig?: object;
state: ModelState;
state: ModelState | undefined;
/**
* Description of the current model state
*/
stateDescription?: string;
recommended?: boolean;
/**
* Model name, e.g. elser
Expand Down Expand Up @@ -374,14 +378,17 @@ export const ModelsList: FC<Props> = ({
...modelStats[0],
deployment_stats: modelStats.map((d) => d.deployment_stats).filter(isDefined),
};

// Extract deployment ids from deployment stats
model.deployment_ids = modelStats
.map((v) => v.deployment_stats?.deployment_id)
.filter(isDefined);
model.state = model.stats.deployment_stats?.some(
(v) => v.state === DEPLOYMENT_STATE.STARTED
)
? DEPLOYMENT_STATE.STARTED
: null;

model.state = getModelDeploymentState(model);
model.stateDescription = model.stats.deployment_stats.reduce((acc, c) => {
if (acc) return acc;
return c.reason ?? '';
}, '');
});

const elasticModels = models.filter((model) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import type {
NetworkTopCountriesColumnsNetworkDetails,
} from '../../network/components/network_top_countries_table/columns';
import type { TlsColumns } from '../../network/components/tls_table/columns';
import type { UncommonProcessTableColumns } from '../../hosts/components/uncommon_process_table';
import type { UncommonProcessTableColumns } from '../../hosts/components/uncommon_process_table/columns';
import type { HostRiskScoreColumns } from '../../../entity_analytics/components/host_risk_score_table';

import type { UsersColumns } from '../../network/components/users_table/columns';
Expand Down
Loading

0 comments on commit fede946

Please sign in to comment.