# Kibana 7.6.1: Getting values from kibana.yml

**URL:** <https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076>\
**Category:** Kibana\
**Created:** [April 8, 2020, 8:07am UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076 "2020-04-08T08:07:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javek](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Javek](https://discuss.elastic.co/u/Javek)\
**Post date:** [April 8, 2020, 8:07am UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/1 "2020-04-08T08:07:14Z")

</div>

Hello. At 7.4.2 kibana i was able to get hosts config value from clusterClient:

```auto
const hosts = server.plugins.elasticsearch.getCluster('data').clusterClient.config.hosts

```

But now at 7.6+ it's seems imposibble because [https://github.com/elastic/kibana/pull/53824](https://github.com/elastic/kibana/pull/53824).

I also tried some solutions from here [Unknown key 'elasticsearch.hosts' for Kibana plugin config](https://discuss.elastic.co/t/unknown-key-elasticsearch-hosts-for-kibana-plugin-config/211254). But it didn't work for me.

Is there any possible solutions to get values from kibana.yml?

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [April 10, 2020, 10:50pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/2 "2020-04-10T22:50:40Z")

</div>

You can gain access to kibana.yml variables with `server.config().get()`. Then in your plugin registration, you can pass any kibana.yml variables to the client with `injectDefaultVars`.

For example

> <https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/maps/index.js#L34>

---

<div class="post-metadata">

**Author:** ![Javek](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Javek](https://discuss.elastic.co/u/Javek)\
**Post date:** [April 13, 2020, 8:11am UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/3 "2020-04-13T08:11:56Z")

</div>

It is not working:

```auto
injectDefaultVars(server) {
  const config = server.config();
  return {
    testHosts: config.get('elasticsearch.hosts'),
  };
},

```

```auto
server error [08:07:09.992] Error: Unknown config key: elasticsearch.hosts
  at Config.get (/home/asf/kibana_source/kibana/src/legacy/server/config/config.js:147:15)
  at fn (/home/asf/kibana_source/kibana/plugins/vms-reporter-kibana-plugin/index.js:27:29)
  ...

```

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [April 13, 2020, 12:05pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/4 "2020-04-13T12:05:50Z")

</div>

You will need to register your new kibana.yml configuration options in joi schema

> <https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/maps/index.js#L82>

---

<div class="post-metadata">

**Author:** ![Javek](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Javek](https://discuss.elastic.co/u/Javek)\
**Post date:** [April 13, 2020, 12:23pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/5 "2020-04-13T12:23:38Z")

</div>

Yes. But error raise when web page loads for the first time (in my case getting `http://localhost:5603/dev/`), not when getting a value from config object.

```auto
      ...
      injectDefaultVars(server) {
        const config = server.config();
        return {
          testHosts: config.get('elasticsearch.hosts'),
        };
      },
    },

    config(Joi) {
      return Joi.object({
        enabled: Joi.boolean().default(true),
        testHosts: Joi.string().default('no hosts')
      }).default();
    },

```

Error when running yarn start:

```auto
server log [12:18:44.826] [info][listening] Server running at http://localhost:5603/dev
server log [12:18:49.865] [info][server][Kibana][http] http server running at http://localhost:5603/dev
server error [12:18:51.014] Error: Unknown config key: elasticsearch.hosts
    at Config.get (/home/asf/kibana_source/kibana/src/legacy/server/config/config.js:147:15)
    at fn (/home/asf/kibana_source/kibana/plugins/vms-reporter-kibana-plugin/index.js:27:29)
    at reduce (/home/asf/kibana_source/kibana/src/core/server/legacy/legacy_internals.ts:50:25)
    at Array.reduce (<anonymous>)
    at LegacyInternals.defaultVars (/home/asf/kibana_source/kibana/src/core/server/legacy/legacy_internals.ts:48:66)
    at LegacyInternals.getVars (/home/asf/kibana_source/kibana/src/core/server/legacy/legacy_internals.ts:89:22)
    at renderApp (/home/asf/kibana_source/kibana/src/legacy/ui/ui_render/ui_render_mixin.js:192:31)
    at internals.Toolkit.renderAppWithDefaultConfig (/home/asf/kibana_source/kibana/src/legacy/ui/ui_render/ui_render_mixin.js:210:12)
    at handler (/home/asf/kibana_source/kibana/plugins/opendistro_security/lib/auth/types/basicauth/routes.js:85:26)
    at module.exports.internals.Manager.execute (/home/asf/kibana_source/kibana/node_modules/hapi/lib/toolkit.js:35:106)
    at Object.internals.handler (/home/asf/kibana_source/kibana/node_modules/hapi/lib/handler.js:50:48)
    at exports.execute (/home/asf/kibana_source/kibana/node_modules/hapi/lib/handler.js:35:36)
    at module.exports.internals.Core.constructor.Request._lifecycle (/home/asf/kibana_source/kibana/node_modules/hapi/lib/request.js:263:62)

```

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [April 13, 2020, 12:53pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/6 "2020-04-13T12:53:31Z")

</div>

That is interesting. It looks like you can not grab kibana.yml configurations from another plugin.

If you take a look at sense plugin, dev tools, then you can see where it grabs elasticsearchUrl contains elasticsearch.hosts.

> <https://github.com/elastic/kibana/blob/master/src/legacy/core_plugins/console_legacy/index.ts#L36>

---

<div class="post-metadata">

**Author:** ![Javek](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Javek](https://discuss.elastic.co/u/Javek)\
**Post date:** [April 13, 2020, 1:39pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/7 "2020-04-13T13:39:46Z")

</div>

```auto
ReferenceError: first is not defined

```

It seems like it's not working on 7.6.1. Btw i looked at 7.6.1 source code of console plugin ([https://github.com/elastic/kibana/blob/v7.6.1/src/legacy/core\_plugins/console/index.ts](https://github.com/elastic/kibana/blob/v7.6.1/src/legacy/core_plugins/console/index.ts)). Here is too much hack code. So I'm thinking about reading and parsing kibana.yml myself.

Also i see that there is a "newPlatform" for plugins. Found some plugins at [https://github.com/elastic/kibana/tree/v7.6.1/src/plugins](https://github.com/elastic/kibana/tree/v7.6.1/src/plugins). But I didn't find any public documentation for developing plugins on the "newPlatform". Are any available? Also kbn-plugin-generator still generates "legacy" plugins in v7.6.1 branch (did not checked v7.6.2).

Thanks for helping

upd. I found migration guide: [https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md](https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 11, 2020, 1:39pm UTC](https://discuss.elastic.co/t/kibana-7-6-1-getting-values-from-kibana-yml/227076/8 "2020-05-11T13:39:49Z")

</div>

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