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

[Index Management] Add enrich policies fetch api and expose in plugin api #163556

Merged

Conversation

sabarasaba
Copy link
Member

@sabarasaba sabarasaba commented Aug 10, 2023

Related to #163159

Summary

In order to unblock the esql team working on the kibana implementation, I'll first merge the API changes for listing enrich policies and a client side public api interface for exposing this mechanism so that the consumer plugins can use it.

Consumers of this plugin can use public apiService from index management by first adding the indexManagement plugin as a dependency of their plugin and then proceding to invoke the method as:

const { data, error } = await indexManagement?.apiService.getAllEnrichPolicies();

Which will then return a serialized list of enriched policies that look something like:

[
    {
      "name": "my-policy",
      "type": "match",
      "sourceIndices": ["users"],
      "matchField": "email",
      "enrichFields": ["first_name", "last_name", "city"]
    },
  ]
How to test
  1. Start elasticsearch with yarn es snapshot --license=trial and serverless search solution with yarn start
  2. Open the ILM/public/plugin.ts file in your text editor and add indexManagement?.apiService.getAllEnrichPolicies();
  3. Go to console and create a test enrich policy
  4. Open ILM policies page and make sure that a request for fetching enrich policies has been fired
Create a policy
PUT /users
{
  "mappings": {
    "properties": {
      "email": {
        "type": "keyword"
      },
      "first_name": {
        "type": "text"
      },
      "last_name": {
        "type": "text"
      },
      "city": {
        "type": "text"
      },
      "zip": {
        "type": "keyword"
      },
      "state": {
        "type": "keyword"
      }
    }
  }
}


PUT /_enrich/policy/my-policy
{
  "match": {
    "indices": "users",
    "match_field": "email",
    "enrich_fields": ["first_name", "last_name", "city", "zip", "state"]
  }
}

@sabarasaba sabarasaba added Feature:Index Management Index and index templates UI Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v8.11.0 labels Aug 10, 2023
@sabarasaba sabarasaba self-assigned this Aug 10, 2023
@sabarasaba sabarasaba changed the title [Index Management] Add enrich policies apis [Index Management] Add enrich policies fetch api and expose in plugin api Aug 10, 2023
@sabarasaba sabarasaba marked this pull request as ready for review August 10, 2023 13:21
@sabarasaba sabarasaba requested a review from a team as a code owner August 10, 2023 13:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/platform-deployment-management (Team:Deployment Management)

@yuliacech yuliacech self-requested a review August 14, 2023 09:57
Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Great job, @sabarasaba! 🚀
Tested locally and the api service works as expected. I left a couple of comments in the code, please let me know what you think.
Other than that, I think we should also add some api integration tests for the new route to this folder, but this could also be done in a separate PR.

@sabarasaba
Copy link
Member Author

@elasticmachine merge upstream

@sabarasaba
Copy link
Member Author

Thanks for the review @yuliacech! I've addressed your comments with a4e984e. In regards of the API integration tests I'll aim to have all of them together in a later iteration to avoid bloating in the PRs. I've created an issue for that and also integrated that into the project plan: #163807

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM! Thanks a lot for addressing my comments 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
indexManagement 491 493 +2

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
indexManagement 172 180 +8

Async chunks

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

id before after diff
indexManagement 523.6KB 522.0KB -1.6KB

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
indexManagement 3 4 +1

Page load bundle

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

id before after diff
indexManagement 27.9KB 32.4KB +4.5KB
Unknown metric groups

API count

id before after diff
indexManagement 177 185 +8

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @sabarasaba

@sabarasaba sabarasaba merged commit ec02f08 into elastic:main Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Index Management Index and index templates UI release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.10.0 v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants