title: How to inject the Elasticsearch service to Kibana controller?
body: <p>I am building a Kibana plugin which will query Elasticsearch on behalf of the user. The <a href="https://www.elastic.co/guide/en/kibana/5.3/development-elasticsearch.html" rel="nofollow noreferrer">official documentation</a> says that I could use the <code>es</code> service from the <code>kibana</code> module.</p>
  
  <pre><code>uiModules
  .get('app/demo', ['kibana'])
  .controller('demoController', function ($scope, esAdmin, es) {
    es.ping()
    .then(() =&gt; esAdmin.ping())
    .catch(err =&gt; {
      console.log('error pinging servers');
    });
  });
  </code></pre>
  
  <p>However, the plugin fails to start with the following error:</p>
  
  <pre><code>Error: [$injector:unpr] Unknown provider: esAdminProvider &lt;- esAdmin &lt;- demoController
  </code></pre>
  
  <p>It seems that the <code>es</code> service is not registered with the <code>kibana</code> module.</p>
  
  <p>Then I tried to copy how <a href="https://www.elastic.co/guide/en/kibana/5.2/console-kibana.html" rel="nofollow noreferrer">Console</a> works. It does not use the Elasticsearch service, but create a proxy API at the server instead. However, I have no idea how Console calls the proxy API with user's authentication information.</p>
  
  <p>I am running out of ideas. Thank you in advance for any help regarding how to query Elasticsearch from the plugin. </p>