Cannot access es service from custom plugin

Hello!

I'm trying to write my own custom Kibana plugin and I want to launch custom ES queries from the client.
According to the documentation, the es service should be a way to go, but I cannot use it, because angularjs says the service is not available, namely:

Uncaught Error: [$injector:modulerr] Failed to instantiate module kibana due to:
Error: [$injector:modulerr] Failed to instantiate module esAdmin due to:
Error: [$injector:nomod] Module 'esAdmin' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.7/$injector/nomod?p0=esAdmin

The code I try to run is (from the plugin app.js):

uiModules.get('kibana', ['esAdmin', 'es'])
.run(function (esAdmin, es) {
  es.ping()
  .then(
    () => {console.log("es pinged");}
   ).catch(err => {
     console.log(err);
   });

Can you tell me what am I doing wrong? (Using Kibana 5.5)

What version of Kibana are you writing a plugin for? The esAdmin proxy was removed in 6.0+. It looks like our docs are out of date, I'll make sure those get updated.

I'm using Kibana 5.5

Also if I just use es and remove esAdmin, I got a simlar exception.
Should I maybe include a specific file for the service to be available?

Uncaught Error: [$injector:modulerr] Failed to instantiate module kibana due to:
Error: [$injector:modulerr] Failed to instantiate module es due to:
Error: [$injector:nomod] Module 'es' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Try

uiModules.get('kibana')
.run(function (esAdmin, es) {
  es.ping()
  .then(
    () => {console.log("es pinged");}
   ).catch(err => {
     console.log(err);
   });

es and esAdmin are just angular services, not modules. This should work in 5.5. Do keep in mind that esAdmin will be gone in 6.0+ though.

Thank you for helping!

I tried it out, now a different exception:

Uncaught Error: [$injector:unpr] Unknown provider: esProvider <- es
http://errors.angularjs.org/1.4.7/$injector/unpr?p0=esProvider%20%3C-%20es (https://localhost:25601/dby/bundles/commons.bundle.js?v=8467:27572)
Version: 5.5.0
Build: 8467

Can you share the full code that's producing that error?

I found out the problem.
I missed out an import.
Adding this line import 'ui/autoload/modules'; solves it.

Sorry, I'm new to Kibana.

1 Like

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