mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[EEM] add entity definition managed flag (#184007)
Adds a `managed` flag to entity definition to determine if it was created by user or by system ### Testing - Create a definition and optionally pass a top level `managed: boolean` flag to it - Verify managed flag is appropriately shown in the response ``` POST kbn:/api/entities/definition { "id": "admin-console-logs-service", "name": "Services for Admin Console", "type": "service", "indexPatterns": ["kbn-data-forge-fake_stack.*"], "timestampField": "@timestamp", "lookback": "5m", "identityFields": ["log.logger"], "identityTemplate": "{{log.logger}}", "metadata": [ "tags", "host.name" ], "metrics": [ { "name": "logRate", "equation": "A / 5", "metrics": [ { "name": "A", "aggregation": "doc_count", "filter": "log.level: *" } ] }, { "name": "errorRate", "equation": "A / 5", "metrics": [ { "name": "A", "aggregation": "doc_count", "filter": "log.level: \"ERROR\"" } ] } ] } ```
This commit is contained in:
parent
6150a221c2
commit
3a0aa1a65b
9 changed files with 12 additions and 11 deletions
|
@ -30,6 +30,7 @@ export const entityDefinitionSchema = z.object({
|
|||
staticFields: z.optional(z.record(z.string(), z.string())),
|
||||
lookback: durationSchema,
|
||||
timestampField: z.string(),
|
||||
managed: z.optional(z.boolean()).default(false),
|
||||
settings: z.optional(
|
||||
z.object({
|
||||
syncField: z.optional(z.string()),
|
||||
|
|
|
@ -29,7 +29,7 @@ export async function createAndInstallIngestPipeline(
|
|||
{ logger }
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error(`Cannot create entity ingest pipeline for [${definition.id}] entity defintion`);
|
||||
logger.error(`Cannot create entity ingest pipeline for [${definition.id}] entity definition`);
|
||||
if (e.meta?.body?.error?.type === 'security_exception') {
|
||||
throw new EntitySecurityException(e.meta.body.error.reason, definition);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export async function deleteEntityDefinition(
|
|||
|
||||
if (response.total === 0) {
|
||||
logger.error(`Unable to delete entity definition [${definition.id}] because it doesn't exist.`);
|
||||
throw new EntityDefinitionNotFound(`Entity defintion with [${definition.id}] not found.`);
|
||||
throw new EntityDefinitionNotFound(`Entity definition with [${definition.id}] not found.`);
|
||||
}
|
||||
|
||||
await soClient.delete(SO_ENTITY_DEFINITION_TYPE, response.saved_objects[0].id);
|
||||
|
|
|
@ -18,7 +18,7 @@ export async function deleteIndex(
|
|||
try {
|
||||
await esClient.indices.delete({ index: indexName, ignore_unavailable: true });
|
||||
} catch (e) {
|
||||
logger.error(`Unable to remove entity defintion index [${definition.id}}]`);
|
||||
logger.error(`Unable to remove entity definition index [${definition.id}}]`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
import { EntityDefinition } from '@kbn/entities-schema';
|
||||
|
||||
export class EntityIdConflict extends Error {
|
||||
public defintion: EntityDefinition;
|
||||
public definition: EntityDefinition;
|
||||
|
||||
constructor(message: string, def: EntityDefinition) {
|
||||
super(message);
|
||||
this.name = 'EntityIdConflict';
|
||||
this.defintion = def;
|
||||
this.definition = def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
import { EntityDefinition } from '@kbn/entities-schema';
|
||||
|
||||
export class EntitySecurityException extends Error {
|
||||
public defintion: EntityDefinition;
|
||||
public definition: EntityDefinition;
|
||||
|
||||
constructor(message: string, def: EntityDefinition) {
|
||||
super(message);
|
||||
this.name = 'EntitySecurityException';
|
||||
this.defintion = def;
|
||||
this.definition = def;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export async function readEntityDefinition(
|
|||
filter: `${SO_ENTITY_DEFINITION_TYPE}.attributes.id:(${id})`,
|
||||
});
|
||||
if (response.total === 0) {
|
||||
const message = `Unable to find entity defintion with [${id}]`;
|
||||
const message = `Unable to find entity definition with [${id}]`;
|
||||
logger.error(message);
|
||||
throw new EntityDefinitionNotFound(message);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export async function readEntityDefinition(
|
|||
try {
|
||||
return entityDefinitionSchema.parse(response.saved_objects[0].attributes);
|
||||
} catch (e) {
|
||||
logger.error(`Unable to parse entity defintion with [${id}]`);
|
||||
logger.error(`Unable to parse entity definition with [${id}]`);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export async function saveEntityDefinition(
|
|||
|
||||
if (response.total === 1) {
|
||||
throw new EntityIdConflict(
|
||||
`Entity defintion with [${definition.id}] already exists.`,
|
||||
`Entity definition with [${definition.id}] already exists.`,
|
||||
definition
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export const entitiesEntityComponentTemplateConfig: ClusterPutComponentTemplateR
|
|||
ignore_above: 1024,
|
||||
type: 'keyword',
|
||||
},
|
||||
defintionId: {
|
||||
definitionId: {
|
||||
ignore_above: 1024,
|
||||
type: 'keyword',
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue