Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eem] _search endpoint / initial entity manager UI #199609

Merged
merged 47 commits into from
Nov 22, 2024

Conversation

klacabane
Copy link
Contributor

@klacabane klacabane commented Nov 11, 2024

Summary

  • create _search endpoint to discover entities with esql queries. It currently reads sources of the provided type from kibana_entity_definitions index. Run this query to insert a definition:
POST kibana_entity_definitions/_doc
{
    "entity_type": "service",
    "index_patterns": ["remote_cluster:logs-*"],
    "metadata_fields": [],
    "identity_fields": ["service.name"],
    "filters": [],
    "timestamp_field": "@timestamp"
}

By default _search will look at data in the last 5m. The lookup period can be overriden by providing start/end parameters in ISO format. It also accepts a limit to specify the number of entities returned which defaults to 10

POST kbn:/internal/entities/v2/_search
{
    "type": "service",
    "start": "2024-11-19T20:40:00.000Z",
    "end": "2024-11-19T20:50:00.000Z",
    "limit": 20
}
  • create _search/preview endpoint to preview output of entity sources without persisting them

  • create UI to preview results of an entity definition at /app/entity_manager. The application is living in its own plugin at observability_solution/entity_manager_app
    Screenshot 2024-11-11 at 11 37 18

@klacabane klacabane changed the base branch from eem-entity-definition-v2 to main November 18, 2024 12:07
@klacabane klacabane marked this pull request as ready for review November 19, 2024 21:04
@klacabane klacabane requested review from a team as code owners November 19, 2024 21:04
@klacabane klacabane added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:obs-entities Observability Entities Team labels Nov 19, 2024
@klacabane klacabane self-assigned this Nov 19, 2024
x-pack/plugins/entity_manager/server/lib/queries/index.ts Outdated Show resolved Hide resolved
sourceCommand(source),
...filterCommands(source),
statsCommand(source),
`SORT entity.last_seen_timestamp DESC`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a source doesn't have a timestamp field, this will error out (i think). we should handle that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp field set on a source is mandatory in this PR so the query will not run if it's not defined

function mergeEntities(entity1: Entity, entity2: Entity): Entity {
const merged: Entity = {
...entity1,
'entity.last_seen_timestamp': new Date(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, i think we have to handle the case of missing last_seen_timestamp

x-pack/packages/kbn-entities-schema/src/schema/entity.ts Outdated Show resolved Hide resolved
@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 22, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: a49c97e
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-199609-a49c97ef15b9

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
entityManagerApp - 45 +45

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/entities-schema 45 50 +5
entityManager 20 35 +15
total +20

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
entityManagerApp - 11.4KB +11.4KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
entityManager 3 2 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
entityManager 7.3KB 7.4KB +70.0B
entityManagerApp - 5.1KB +5.1KB
total +5.2KB
Unknown metric groups

API count

id before after diff
@kbn/entities-schema 45 50 +5
entityManager 20 35 +15
total +20

async chunk count

id before after diff
entityManagerApp - 1 +1

History

cc @klacabane

@klacabane klacabane merged commit 0b3f4fb into elastic:main Nov 22, 2024
43 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11975189293

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Nov 25, 2024
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 199609 locally

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 199609 locally

paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
## Summary

- create `_search` endpoint to discover entities with esql queries. It
currently reads sources of the provided `type` from
`kibana_entity_definitions` index. Run this query to insert a
definition:
```
POST kibana_entity_definitions/_doc
{
    "entity_type": "service",
    "index_patterns": ["remote_cluster:logs-*"],
    "metadata_fields": [],
    "identity_fields": ["service.name"],
    "filters": [],
    "timestamp_field": "@timestamp"
}
```

By default `_search` will look at data in the last 5m. The lookup period
can be overriden by providing `start`/`end` parameters in ISO format. It
also accepts a `limit` to specify the number of entities returned which
defaults to 10

```
POST kbn:/internal/entities/v2/_search
{
    "type": "service",
    "start": "2024-11-19T20:40:00.000Z",
    "end": "2024-11-19T20:50:00.000Z",
    "limit": 20
}
```

- create `_search/preview` endpoint to preview output of entity sources
without persisting them
 
- create UI to preview results of an entity definition at
`/app/entity_manager`. The application is living in its own plugin at
`observability_solution/entity_manager_app`
![Screenshot 2024-11-11 at 11 37
18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Milton Hultgren <[email protected]>
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 199609 locally

klacabane added a commit to klacabane/kibana that referenced this pull request Nov 27, 2024
## Summary

- create `_search` endpoint to discover entities with esql queries. It
currently reads sources of the provided `type` from
`kibana_entity_definitions` index. Run this query to insert a
definition:
```
POST kibana_entity_definitions/_doc
{
    "entity_type": "service",
    "index_patterns": ["remote_cluster:logs-*"],
    "metadata_fields": [],
    "identity_fields": ["service.name"],
    "filters": [],
    "timestamp_field": "@timestamp"
}
```

By default `_search` will look at data in the last 5m. The lookup period
can be overriden by providing `start`/`end` parameters in ISO format. It
also accepts a `limit` to specify the number of entities returned which
defaults to 10

```
POST kbn:/internal/entities/v2/_search
{
    "type": "service",
    "start": "2024-11-19T20:40:00.000Z",
    "end": "2024-11-19T20:50:00.000Z",
    "limit": 20
}
```

- create `_search/preview` endpoint to preview output of entity sources
without persisting them

- create UI to preview results of an entity definition at
`/app/entity_manager`. The application is living in its own plugin at
`observability_solution/entity_manager_app`
![Screenshot 2024-11-11 at 11 37
18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Milton Hultgren <[email protected]>
(cherry picked from commit 0b3f4fb)

# Conflicts:
#	.github/CODEOWNERS
@klacabane
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

klacabane added a commit that referenced this pull request Nov 28, 2024
…202050)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[eem] _search endpoint / initial entity manager UI
(#199609)](#199609)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Lacabane","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-22T15:12:04Z","message":"[eem]
_search endpoint / initial entity manager UI (#199609)\n\n##
Summary\r\n\r\n- create `_search` endpoint to discover entities with
esql queries. It\r\ncurrently reads sources of the provided `type`
from\r\n`kibana_entity_definitions` index. Run this query to insert
a\r\ndefinition:\r\n```\r\nPOST kibana_entity_definitions/_doc\r\n{\r\n
\"entity_type\": \"service\",\r\n \"index_patterns\":
[\"remote_cluster:logs-*\"],\r\n \"metadata_fields\": [],\r\n
\"identity_fields\": [\"service.name\"],\r\n \"filters\": [],\r\n
\"timestamp_field\": \"@timestamp\"\r\n}\r\n```\r\n\r\nBy default
`_search` will look at data in the last 5m. The lookup period\r\ncan be
overriden by providing `start`/`end` parameters in ISO format.
It\r\nalso accepts a `limit` to specify the number of entities returned
which\r\ndefaults to 10\r\n\r\n```\r\nPOST
kbn:/internal/entities/v2/_search\r\n{\r\n \"type\": \"service\",\r\n
\"start\": \"2024-11-19T20:40:00.000Z\",\r\n \"end\":
\"2024-11-19T20:50:00.000Z\",\r\n \"limit\": 20\r\n}\r\n```\r\n\r\n-
create `_search/preview` endpoint to preview output of entity
sources\r\nwithout persisting them\r\n \r\n- create UI to preview
results of an entity definition at\r\n`/app/entity_manager`. The
application is living in its own plugin
at\r\n`observability_solution/entity_manager_app`\r\n![Screenshot
2024-11-11 at 11
37\r\n18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Milton Hultgren
<[email protected]>","sha":"0b3f4fbd3cd60663289fc13f8f01e3f4c9131479","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-entities"],"number":199609,"url":"https://github.com/elastic/kibana/pull/199609","mergeCommit":{"message":"[eem]
_search endpoint / initial entity manager UI (#199609)\n\n##
Summary\r\n\r\n- create `_search` endpoint to discover entities with
esql queries. It\r\ncurrently reads sources of the provided `type`
from\r\n`kibana_entity_definitions` index. Run this query to insert
a\r\ndefinition:\r\n```\r\nPOST kibana_entity_definitions/_doc\r\n{\r\n
\"entity_type\": \"service\",\r\n \"index_patterns\":
[\"remote_cluster:logs-*\"],\r\n \"metadata_fields\": [],\r\n
\"identity_fields\": [\"service.name\"],\r\n \"filters\": [],\r\n
\"timestamp_field\": \"@timestamp\"\r\n}\r\n```\r\n\r\nBy default
`_search` will look at data in the last 5m. The lookup period\r\ncan be
overriden by providing `start`/`end` parameters in ISO format.
It\r\nalso accepts a `limit` to specify the number of entities returned
which\r\ndefaults to 10\r\n\r\n```\r\nPOST
kbn:/internal/entities/v2/_search\r\n{\r\n \"type\": \"service\",\r\n
\"start\": \"2024-11-19T20:40:00.000Z\",\r\n \"end\":
\"2024-11-19T20:50:00.000Z\",\r\n \"limit\": 20\r\n}\r\n```\r\n\r\n-
create `_search/preview` endpoint to preview output of entity
sources\r\nwithout persisting them\r\n \r\n- create UI to preview
results of an entity definition at\r\n`/app/entity_manager`. The
application is living in its own plugin
at\r\n`observability_solution/entity_manager_app`\r\n![Screenshot
2024-11-11 at 11
37\r\n18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Milton Hultgren
<[email protected]>","sha":"0b3f4fbd3cd60663289fc13f8f01e3f4c9131479"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199609","number":199609,"mergeCommit":{"message":"[eem]
_search endpoint / initial entity manager UI (#199609)\n\n##
Summary\r\n\r\n- create `_search` endpoint to discover entities with
esql queries. It\r\ncurrently reads sources of the provided `type`
from\r\n`kibana_entity_definitions` index. Run this query to insert
a\r\ndefinition:\r\n```\r\nPOST kibana_entity_definitions/_doc\r\n{\r\n
\"entity_type\": \"service\",\r\n \"index_patterns\":
[\"remote_cluster:logs-*\"],\r\n \"metadata_fields\": [],\r\n
\"identity_fields\": [\"service.name\"],\r\n \"filters\": [],\r\n
\"timestamp_field\": \"@timestamp\"\r\n}\r\n```\r\n\r\nBy default
`_search` will look at data in the last 5m. The lookup period\r\ncan be
overriden by providing `start`/`end` parameters in ISO format.
It\r\nalso accepts a `limit` to specify the number of entities returned
which\r\ndefaults to 10\r\n\r\n```\r\nPOST
kbn:/internal/entities/v2/_search\r\n{\r\n \"type\": \"service\",\r\n
\"start\": \"2024-11-19T20:40:00.000Z\",\r\n \"end\":
\"2024-11-19T20:50:00.000Z\",\r\n \"limit\": 20\r\n}\r\n```\r\n\r\n-
create `_search/preview` endpoint to preview output of entity
sources\r\nwithout persisting them\r\n \r\n- create UI to preview
results of an entity definition at\r\n`/app/entity_manager`. The
application is living in its own plugin
at\r\n`observability_solution/entity_manager_app`\r\n![Screenshot
2024-11-11 at 11
37\r\n18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Milton Hultgren
<[email protected]>","sha":"0b3f4fbd3cd60663289fc13f8f01e3f4c9131479"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
@kibanamachine kibanamachine added v8.18.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Nov 28, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## Summary

- create `_search` endpoint to discover entities with esql queries. It
currently reads sources of the provided `type` from
`kibana_entity_definitions` index. Run this query to insert a
definition:
```
POST kibana_entity_definitions/_doc
{
    "entity_type": "service",
    "index_patterns": ["remote_cluster:logs-*"],
    "metadata_fields": [],
    "identity_fields": ["service.name"],
    "filters": [],
    "timestamp_field": "@timestamp"
}
```

By default `_search` will look at data in the last 5m. The lookup period
can be overriden by providing `start`/`end` parameters in ISO format. It
also accepts a `limit` to specify the number of entities returned which
defaults to 10

```
POST kbn:/internal/entities/v2/_search
{
    "type": "service",
    "start": "2024-11-19T20:40:00.000Z",
    "end": "2024-11-19T20:50:00.000Z",
    "limit": 20
}
```

- create `_search/preview` endpoint to preview output of entity sources
without persisting them
 
- create UI to preview results of an entity definition at
`/app/entity_manager`. The application is living in its own plugin at
`observability_solution/entity_manager_app`
![Screenshot 2024-11-11 at 11 37
18](https://github.com/user-attachments/assets/f284342d-21a3-4ba1-be94-38cff311266c)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Milton Hultgren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-entities Observability Entities Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants