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

Elasticsearch service should provide a better way of registering custom ElasticsearchJS client "actions" #31934

Closed
azasypkin opened this issue Feb 25, 2019 · 4 comments
Labels
Feature:New Platform stale Used to mark issues that were closed for being stale Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@azasypkin
Copy link
Member

Once we merge #28344, core ElasticsearchService will be used to access Elasticsearch from both new and legacy platform. There is a bunch of places in Kibana where we create cluster clients with custom ElasticsearchJS client "actions". These actions are configured via plugins property of ElasticsearchClientConfig that has direct access to the underlying ElasticsearchJS client. E.g.:

const cluster = server.plugins.elasticsearch.createCluster('admin', {
  plugins: [monitoringBulk],
});

............monitoringBulk............

export function monitoringBulk(Client, _config, components) {
  Client.prototype.monitoring = components.clientAction.namespaceFactory();
  Client.prototype.monitoring.prototype.bulk = components.clientAction.factory({
    params: {
      system_id: {
        type: 'string'
      },
    },
    urls: [{
      fmt: '/_monitoring/<%=type%>/bulk',
      req: { type: { type: 'string' } }
    }],
    needBody: true,
    method: 'POST'
  });
}

This is basically a hole we left open because of BWC reasons and we should find a better way to accomplish the same thing with more controlled and convenient API that doesn't expose ElasticsearchJS client internals.

@azasypkin azasypkin added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Feb 25, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@epixa
Copy link
Contributor

epixa commented Feb 25, 2019

The new elasticsearch-js client supports registering actions on an existing client. We should prioritize moving to that client interface so creating custom client classes and modifying prototypes is not necessary.

@azasypkin
Copy link
Member Author

That's awesome! There is definitely some non-zero amount of work is necessary on our side to support that though, so I'll keep this open.

@mshustov
Copy link
Contributor

mshustov commented Oct 3, 2019

should be done in #35508

@joshdover joshdover added the stale Used to mark issues that were closed for being stale label Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform stale Used to mark issues that were closed for being stale Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

5 participants