forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ECO][Inventory] Redirect ECS k8s entities to dashboards (elastic#197222
) closes [elastic#196142](elastic#196142) ## Summary Links kubernetes ECS entities to their corresponding dashboards > [!IMPORTANT] > ECS `replicaset` doesn't have a dedicated dashboard. `container` will be handled in a separate ticket > Semconv won't link to any dashboard/page <img width="800" alt="image" src="https://github.com/user-attachments/assets/711dbd28-f0ef-4af0-a658-afe7f1595697"> ![redirect](https://github.com/user-attachments/assets/77d5d2e1-7ec4-40cd-b7d8-419e07e6b760) ### How to test - While elastic#196916 is not merged, change `ENTITIES_LATEST_ALIAS` constant to `'.entities.v1.latest*'` - Start a local kibana and es instances - Run ` node scripts/synthtrace k8s_entities.ts --live --clean ` - Run `PUT kbn:/internal/entities/managed/enablement` on the devtools - Install the kubernetes integration package to have the dashboards installed. - Navigate to `Inventory` and click through the k8s entities --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
b12e7d0
commit 8145cb7
Showing
28 changed files
with
715 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
.../packages/observability/observability_utils/es/utils/esql_result_to_plain_objects.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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 type { ESQLSearchResponse } from '@kbn/es-types'; | ||
import { esqlResultToPlainObjects } from './esql_result_to_plain_objects'; | ||
|
||
describe('esqlResultToPlainObjects', () => { | ||
it('should return an empty array for an empty result', () => { | ||
const result: ESQLSearchResponse = { | ||
columns: [], | ||
values: [], | ||
}; | ||
const output = esqlResultToPlainObjects(result); | ||
expect(output).toEqual([]); | ||
}); | ||
|
||
it('should return plain objects', () => { | ||
const result: ESQLSearchResponse = { | ||
columns: [{ name: 'name', type: 'keyword' }], | ||
values: [['Foo Bar']], | ||
}; | ||
const output = esqlResultToPlainObjects(result); | ||
expect(output).toEqual([{ name: 'Foo Bar' }]); | ||
}); | ||
|
||
it('should return columns without "text" or "keyword" in their names', () => { | ||
const result: ESQLSearchResponse = { | ||
columns: [ | ||
{ name: 'name.text', type: 'text' }, | ||
{ name: 'age', type: 'keyword' }, | ||
], | ||
values: [ | ||
['Foo Bar', 30], | ||
['Foo Qux', 25], | ||
], | ||
}; | ||
const output = esqlResultToPlainObjects(result); | ||
expect(output).toEqual([ | ||
{ name: 'Foo Bar', age: 30 }, | ||
{ name: 'Foo Qux', age: 25 }, | ||
]); | ||
}); | ||
|
||
it('should handle mixed columns correctly', () => { | ||
const result: ESQLSearchResponse = { | ||
columns: [ | ||
{ name: 'name', type: 'text' }, | ||
{ name: 'name.text', type: 'text' }, | ||
{ name: 'age', type: 'keyword' }, | ||
], | ||
values: [ | ||
['Foo Bar', 'Foo Bar', 30], | ||
['Foo Qux', 'Foo Qux', 25], | ||
], | ||
}; | ||
const output = esqlResultToPlainObjects(result); | ||
expect(output).toEqual([ | ||
{ name: 'Foo Bar', age: 30 }, | ||
{ name: 'Foo Qux', age: 25 }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
x-pack/plugins/entity_manager/public/lib/entity_client.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* 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 { EntityClient, EnitityInstance } from './entity_client'; | ||
import { coreMock } from '@kbn/core/public/mocks'; | ||
|
||
const commonEntityFields: EnitityInstance = { | ||
entity: { | ||
last_seen_timestamp: '2023-10-09T00:00:00Z', | ||
id: '1', | ||
display_name: 'entity_name', | ||
definition_id: 'entity_definition_id', | ||
} as EnitityInstance['entity'], | ||
}; | ||
|
||
describe('EntityClient', () => { | ||
let entityClient: EntityClient; | ||
|
||
beforeEach(() => { | ||
entityClient = new EntityClient(coreMock.createStart()); | ||
}); | ||
|
||
describe('asKqlFilter', () => { | ||
it('should return the kql filter', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['service.name', 'service.environment'], | ||
type: 'service', | ||
}, | ||
service: { | ||
name: 'my-service', | ||
}, | ||
}; | ||
|
||
const result = entityClient.asKqlFilter(entityLatest); | ||
expect(result).toEqual('service.name: my-service'); | ||
}); | ||
|
||
it('should return the kql filter when indentity_fields is composed by multiple fields', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['service.name', 'service.environment'], | ||
type: 'service', | ||
}, | ||
service: { | ||
name: 'my-service', | ||
environment: 'staging', | ||
}, | ||
}; | ||
|
||
const result = entityClient.asKqlFilter(entityLatest); | ||
expect(result).toEqual('(service.name: my-service AND service.environment: staging)'); | ||
}); | ||
|
||
it('should ignore fields that are not present in the entity', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['host.name', 'foo.bar'], | ||
}, | ||
host: { | ||
name: 'my-host', | ||
}, | ||
}; | ||
|
||
const result = entityClient.asKqlFilter(entityLatest); | ||
expect(result).toEqual('host.name: my-host'); | ||
}); | ||
}); | ||
|
||
describe('getIdentityFieldsValue', () => { | ||
it('should return identity fields values', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['service.name', 'service.environment'], | ||
type: 'service', | ||
}, | ||
service: { | ||
name: 'my-service', | ||
}, | ||
}; | ||
|
||
expect(entityClient.getIdentityFieldsValue(entityLatest)).toEqual({ | ||
'service.name': 'my-service', | ||
}); | ||
}); | ||
|
||
it('should return identity fields values when indentity_fields is composed by multiple fields', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['service.name', 'service.environment'], | ||
type: 'service', | ||
}, | ||
service: { | ||
name: 'my-service', | ||
environment: 'staging', | ||
}, | ||
}; | ||
|
||
expect(entityClient.getIdentityFieldsValue(entityLatest)).toEqual({ | ||
'service.name': 'my-service', | ||
'service.environment': 'staging', | ||
}); | ||
}); | ||
|
||
it('should return identity fields when field is in the root', () => { | ||
const entityLatest: EnitityInstance = { | ||
entity: { | ||
...commonEntityFields.entity, | ||
identity_fields: ['name'], | ||
type: 'service', | ||
}, | ||
name: 'foo', | ||
}; | ||
|
||
expect(entityClient.getIdentityFieldsValue(entityLatest)).toEqual({ | ||
name: 'foo', | ||
}); | ||
}); | ||
|
||
it('should throw an error when identity fields are missing', () => { | ||
const entityLatest: EnitityInstance = { | ||
...commonEntityFields, | ||
}; | ||
|
||
expect(() => entityClient.getIdentityFieldsValue(entityLatest)).toThrow( | ||
'Identity fields are missing' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
x-pack/plugins/observability_solution/apm/common/entities/types.ts
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
x-pack/plugins/observability_solution/apm/common/es_fields/entities.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.