Kibana: Uncaught Error: [$injector:unpr] Unknown provider: kbnIndexProvider <- kbnIndex <- config

Created on 7 Mar 2016  路  4Comments  路  Source: elastic/kibana

I try to write a Kibana app and its working well with the current master version of Kibana (Version 5).
But the plugin is not running within Kibana 4.4 (and also not in 4.2/4.3, 4.5 snapshot is also failing). The issue i'am facing is this one:

Uncaught Error: [$injector:unpr] Unknown provider: kbnIndexProvider <- kbnIndex <- config
http://errors.angularjs.org/1.4.7/$injector/unpr?p0=kbnIndexProvider%20%3C-%20kbnIndex%20%3C-%20config (http://localhost:5601/bundles/commons.bundle.js?v=9863:31533)

Version: 4.5.0-snapshot
Build: 9863

Error: Uncaught Error: [$injector:unpr] Unknown provider: kbnIndexProvider <- kbnIndex <- config
http://errors.angularjs.org/1.4.7/$injector/unpr?p0=kbnIndexProvider%20%3C-%20kbnIndex%20%3C-%20config (http://localhost:5601/bundles/commons.bundle.js?v=9863:31533)
    at window.onerror (http://localhost:5601/bundles/commons.bundle.js?v=9863:65461:25)

There is already a closed issue (https://github.com/elastic/kibana/issues/5349) addressing this but for me this is not solved yet.

See also https://discuss.elastic.co/t/unknown-provider-error-in-kibana/43496

Most helpful comment

add this in your index.js. it should work fine. Did for me.

       injectVars: function (server, options) {
         var config = server.config();
         return {
             kbnIndex: config.get('kibana.index'),
             esShardTimeout: config.get('elasticsearch.shardTimeout'),
             esApiVersion: config.get('elasticsearch.apiVersion')
         };
       }

All 4 comments

@salyh the same solution from #5349 would have to be applied to your app, and it will look a lot like https://github.com/elastic/kibana/pull/6173.

Basically, there are kibana modules that don't properly map out their dependencies and when requiring things from ui/* modules don't always get their dependencies loaded properly. This isn't something we plan to fix in older versions of Kibana, and something we plan to fix as we come across it in newer versions.

For now, the easiest solution for you would be to autoload everything as part of your application, but this will add significant weight to your application.

The more complex solution is to map the dependencies that aren't properly mapped (like I did in https://github.com/elastic/kibana/pull/6173). If you are interested in this approach let me know and I can go into more detail about how that works.

Closing, since there aren't action items here, but feel free to respond.

add this in your index.js. it should work fine. Did for me.

       injectVars: function (server, options) {
         var config = server.config();
         return {
             kbnIndex: config.get('kibana.index'),
             esShardTimeout: config.get('elasticsearch.shardTimeout'),
             esApiVersion: config.get('elasticsearch.apiVersion')
         };
       }

@spalger would you mind to elaborate on the approach you used on #6173?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

socialmineruser1 picture socialmineruser1  路  3Comments

ctindel picture ctindel  路  3Comments

timroes picture timroes  路  3Comments

tbragin picture tbragin  路  3Comments

treussart picture treussart  路  3Comments