Unknown key 'elasticsearch.hosts' for Kibana plugin config

Continuing the discussion from Retrieve elasticsearch.hosts from Kibana config in plugin:

I am using Elastic stack 7.4.2 and I am having this simple issue with just getting the configured elasticsearch hosts. It should not be more difficult than

server.config().get('elasticsearch.hosts')

but I get the error "Unknown config key: elasticsearch.hosts". When I do a console.log of my config, I see that elasticsearch only has one key: enabled: true. Why is it that the configuration is not accessible?

In my kibana.yml I have elasticsearch.hosts: ['http://localhost:9299'] configured and kibana receives data, so the configuration itself must be correct.

Hi @Elaak,

Well, Kibana is in a process of migration to a so called new platform. And this config is no longer a part of the plugin contract (APIs that custom plugins have access to). Currently you can still access it through BWC hook, but there is no guarantee that it will be available in 8.0:

const legacyEsConfig = await server.newPlatform.__internals.elasticsearch.legacy.config$
        .pipe(first())
        .toPromise();
const hosts = legacyEsConfig.hosts;

May I ask you why you need to access this value? Also maybe it's a good time for you to start writing "New Platform" plugins (assuming the new platform provides you with all necessary APIs already, see examples here and here).

Best,
Oleg

Hi @azasypkin,

Thank you for the quick answer.

This morning I found out about the elasticsearch client that I can implement in Kibana instead. The plan was otherwise to make a call to the elasticsearch API for my task, but I tested your solution in case I in the future need to access other values from this config.

Currently we have decided to stay at version 7.4 for our setup so the plugin has to be developed for that version.

Thank you for the quick answer.

This morning I found out about the elasticsearch client that I can implement in Kibana instead. The plan was otherwise to make a call to the elasticsearch API for my task, but I tested your solution in case I in the future need to access other values from this config.

Currently we have decided to stay at version 7.4 for our setup so the plugin has to be developed for that version.

:+1:

Currently we have decided to stay at version 7.4 for our setup so the plugin has to be developed for that version.

Sure, just wanted to note that new platform plugins are already supported in 7.4 as well, it's just an amount of APIs that are available is limited and constantly increasing. The plan is to support new platform plugins only since 8.0 - so make sure to allocate some time to migrate before next major version upgrade.

Thanks, I will keep that in mind for the ongoing development next year.

Hi @Elaak @azasypkin
I did not get the solution here.
I am using Kibana 7.4.2, and I have properly configured kibana.yml and I get the same error while starting the service.
I am using the kibana_own_home plugin.
Could you please explain what exactly I am supposed to do to get over the error ?
I am stuck !!

Hey @Inno_Park,

Do you also use server.config().get('elasticsearch.hosts') in your plugin? If not, then please create a new thread to avoid mixing two unrelated issues.

Best,
Oleg

yes thats what we use

So, then just use suggestion from Unknown key 'elasticsearch.hosts' for Kibana plugin config - #2 by azasypkin. Or it doesn't work for you for some reason?

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