Skip to content

Commit

Permalink
[SecuritySolution] Entity Engine status tab (elastic#201235)
Browse files Browse the repository at this point in the history
## Summary

* Add two tabs to the Entity Store page
  * The import entities tab has all the bulk upload content
  * The status tab has the new content created on this PR
* Move the "clear entity store data" button to the header according to
design mockups.
* Delete unused stats route
* Rename `enablement` API docs to `enable`
* Add a new parameter to the status API (`withComponents`)
  * Should I make it snake cased?

### import entities tab
![Screenshot 2024-11-27 at 15 07
01](https://github.com/user-attachments/assets/c433e217-781e-4792-8695-2ee609efa654)

### status tab
![Screenshot 2024-11-27 at 15 07
20](https://github.com/user-attachments/assets/8970c023-22b3-4e83-a444-fa3ccf78ea42)

## How to test it
- Open security solution app with data
- Go to entity store page
- You shouldn't see the new tab because the engine is disabled
- Enable the engine and wait
- Click on the new tab that showed up
- It should list user and host engine components, and everything should
be installed
- Delete or misconfigure some of the resources, the new status should be
reflected on the tab.

## TODO:
- [x] Rebase main after elastic#199762 is
merged
  - [x] Remove temporary status hook
- [x] Fix the"clear entity data" button. It should re-fetch the status
API.

### Checklist

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 06b7993)

# Conflicts:
#	oas_docs/output/kibana.serverless.yaml
#	x-pack/plugins/security_solution/docs/openapi/ess/security_solution_entity_analytics_api_2023_10_31.bundled.schema.yaml
#	x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_entity_analytics_api_2023_10_31.bundled.schema.yaml
#	x-pack/test/api_integration/services/security_solution_api.gen.ts
  • Loading branch information
machadoum committed Dec 3, 2024
1 parent 06256a3 commit 249aae3
Show file tree
Hide file tree
Showing 39 changed files with 53,478 additions and 409 deletions.
51,873 changes: 51,873 additions & 0 deletions oas_docs/output/kibana.serverless.yaml

Large diffs are not rendered by default.

94 changes: 58 additions & 36 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11011,41 +11011,6 @@ paths:
summary: Start an Entity Engine
tags:
- Security Entity Analytics API
/api/entity_store/engines/{entityType}/stats:
post:
operationId: GetEntityEngineStats
parameters:
- description: The entity type of the engine (either 'user' or 'host').
in: path
name: entityType
required: true
schema:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EntityType'
responses:
'200':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
type: object
properties:
indexPattern:
$ref: '#/components/schemas/Security_Entity_Analytics_API_IndexPattern'
indices:
items:
type: object
type: array
status:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineStatus'
transforms:
items:
type: object
type: array
type:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EntityType'
description: Successful response
summary: Get Entity Engine stats
tags:
- Security Entity Analytics API
/api/entity_store/engines/{entityType}/stop:
post:
operationId: StopEntityEngine
Expand Down Expand Up @@ -11196,6 +11161,12 @@ paths:
/api/entity_store/status:
get:
operationId: GetEntityStoreStatus
parameters:
- description: If true returns a detailed status of the engine including all it's components
in: query
name: include_components
schema:
type: boolean
responses:
'200':
content:
Expand All @@ -11205,10 +11176,20 @@ paths:
properties:
engines:
items:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineDescriptor'
allOf:
- $ref: '#/components/schemas/Security_Entity_Analytics_API_EngineDescriptor'
- type: object
properties:
components:
items:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineComponentStatus'
type: array
type: array
status:
$ref: '#/components/schemas/Security_Entity_Analytics_API_StoreStatus'
required:
- status
- engines
description: Successful response
summary: Get the status of the Entity Store
tags:
Expand Down Expand Up @@ -38949,6 +38930,47 @@ components:
$ref: '#/components/schemas/Security_Entity_Analytics_API_AssetCriticalityLevel'
required:
- criticality_level
Security_Entity_Analytics_API_EngineComponentResource:
enum:
- entity_engine
- entity_definition
- index
- component_template
- index_template
- ingest_pipeline
- enrich_policy
- task
- transform
type: string
Security_Entity_Analytics_API_EngineComponentStatus:
type: object
properties:
errors:
items:
type: object
properties:
message:
type: string
title:
type: string
type: array
health:
enum:
- green
- yellow
- red
- unknown
type: string
id:
type: string
installed:
type: boolean
resource:
$ref: '#/components/schemas/Security_Entity_Analytics_API_EngineComponentResource'
required:
- id
- installed
- resource
Security_Entity_Analytics_API_EngineDataviewUpdateResult:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,37 @@ export const EngineDescriptor = z.object({
error: z.object({}).optional(),
});

export type EngineComponentResource = z.infer<typeof EngineComponentResource>;
export const EngineComponentResource = z.enum([
'entity_engine',
'entity_definition',
'index',
'component_template',
'index_template',
'ingest_pipeline',
'enrich_policy',
'task',
'transform',
]);
export type EngineComponentResourceEnum = typeof EngineComponentResource.enum;
export const EngineComponentResourceEnum = EngineComponentResource.enum;

export type EngineComponentStatus = z.infer<typeof EngineComponentStatus>;
export const EngineComponentStatus = z.object({
id: z.string(),
installed: z.boolean(),
resource: EngineComponentResource,
health: z.enum(['green', 'yellow', 'red', 'unknown']).optional(),
errors: z
.array(
z.object({
title: z.string().optional(),
message: z.string().optional(),
})
)
.optional(),
});

export type StoreStatus = z.infer<typeof StoreStatus>;
export const StoreStatus = z.enum(['not_installed', 'installing', 'running', 'stopped', 'error']);
export type StoreStatusEnum = typeof StoreStatus.enum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,49 @@ components:
- updating
- error

EngineComponentStatus:
type: object
required:
- id
- installed
- resource
properties:
id:
type: string
installed:
type: boolean
resource:
$ref: '#/components/schemas/EngineComponentResource'
health:
type: string
enum:
- green
- yellow
- red
- unknown
errors:
type: array
items:
type: object
properties:
title:
type: string
message:
type: string

EngineComponentResource:
type: string
enum:
- entity_engine
- entity_definition
- index
- component_template
- index_template
- ingest_pipeline
- enrich_policy
- task
- transform

StoreStatus:
type: string
enum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

import { z } from '@kbn/zod';

import { IndexPattern, EngineDescriptor, StoreStatus } from './common.gen';

export type GetEntityStoreStatusResponse = z.infer<typeof GetEntityStoreStatusResponse>;
export const GetEntityStoreStatusResponse = z.object({
status: StoreStatus.optional(),
engines: z.array(EngineDescriptor).optional(),
});
import { IndexPattern, EngineDescriptor } from './common.gen';

export type InitEntityStoreRequestBody = z.infer<typeof InitEntityStoreRequestBody>;
export const InitEntityStoreRequestBody = z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,3 @@ paths:
type: array
items:
$ref: './common.schema.yaml#/components/schemas/EngineDescriptor'

/api/entity_store/status:
get:
x-labels: [ess, serverless]
x-codegen-enabled: true
operationId: GetEntityStoreStatus
summary: Get the status of the Entity Store
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
status:
$ref: './common.schema.yaml#/components/schemas/StoreStatus'
engines:
type: array
items:
$ref: './common.schema.yaml#/components/schemas/EngineDescriptor'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export * from './get.gen';
export * from './init.gen';
export * from './list.gen';
export * from './start.gen';
export * from './stats.gen';
export * from './stop.gen';
export * from './apply_dataview_indices.gen';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.
*/

/*
* NOTICE: Do not edit this file manually.
* This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator.
*
* info:
* title: Enable Entity Store
* version: 2023-10-31
*/

import { z } from '@kbn/zod';
import { BooleanFromString } from '@kbn/zod-helpers';

import { StoreStatus, EngineDescriptor, EngineComponentStatus } from './common.gen';

export type GetEntityStoreStatusRequestQuery = z.infer<typeof GetEntityStoreStatusRequestQuery>;
export const GetEntityStoreStatusRequestQuery = z.object({
/**
* If true returns a detailed status of the engine including all it's components
*/
include_components: BooleanFromString.optional(),
});
export type GetEntityStoreStatusRequestQueryInput = z.input<
typeof GetEntityStoreStatusRequestQuery
>;

export type GetEntityStoreStatusResponse = z.infer<typeof GetEntityStoreStatusResponse>;
export const GetEntityStoreStatusResponse = z.object({
status: StoreStatus,
engines: z.array(
EngineDescriptor.merge(
z.object({
components: z.array(EngineComponentStatus).optional(),
})
)
),
});
Loading

0 comments on commit 249aae3

Please sign in to comment.