Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch: v2.9.0
Dashboard: v2.9.0
Describe the issue:
Hi,
I created a dashboard plugin and want to get cluster information from OpenSearch. However, I don’t know how to query OpenSearch from within the plugin. I wrote the following code, but it will break if the OpenSearch host changes:
const baseUrl = 'http://localhost:9200';
export const getClusterStats = async () => {
const response = await fetch(baseUrl + '/_cluster/stats')
return await response.json()
This code is hard-coded to use the OpenSearch host localhost:9200
. If the OpenSearch host changes, the code will need to be updated manually.
Is there a way to change the code so that it is more portable and will not break if the OpenSearch host changes?