Kibana 6 plugin server/API setup not working

Back in Kibana 4.5.0, I had a plugin acting as a REST API endpoint using the following code:

// plugins/plugin_name/index.js
export default function (kibana) {
  const http = require('http');

  return new kibana.Plugin({
    config: Joi => {
      return Joi.object({
        enabled: Joi.boolean().default(true)
    require: ['kibana'],
    init(server, options) {

        method: 'POST',
        path: '...',
        handler: (req, reply) => { ... }

// tasks/config/copy.js
installPlugins: {
  options: { mode: true },
  src: [
  dest: 'build/kibana',
  expand: true

I then call the API endpoint using the $http module within a visualization. I have ported the code to Kibana 6 and though, in the logs, it says that the plugin's status changed from uninitialized to green - ready, the client returns a 404 when hitting the API endpoint.

I can't seem to find the new way of doing this in the docs, so if anyone has any ideas, let me know! Thank you!

This code looks like it should work. The only thing I can think of is maybe the client is not using the right path to hit this endpoint. Can you confirm that the client is using the right base for the path it constructs? If the endpoint is defined with the path '/foo/bar/' the client needs to append that to the path Kibana lives at (this path is generated when Kibana starts up).

Ok that might be it: in plugins/plugin_name/index.js, I define path to be /my_path/my_endpoint and use /my_path/my_endpoint for url in the client.

You mean to add ${ kibana.full_path }/my_path/my_endpoint for it to work? If so, how do I have access to that variable programmatically from the client?

Thanks for the quick reply!

Yes there is an API to add the basepath:

import chrome from 'ui/chrome';

const apiPath = chrome.addBasePath(YOUR_PATH);

Yep, that did the trick. Awesome and thank you so much!

Awesome, glad to hear.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.