diff --git a/docs/sources/datasources/elasticsearch.md b/docs/sources/datasources/elasticsearch.md index 1d1593ca0e2..b81691f04a2 100644 --- a/docs/sources/datasources/elasticsearch.md +++ b/docs/sources/datasources/elasticsearch.md @@ -25,32 +25,12 @@ Supported Elasticsearch versions: > **Note:** If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. -| Name | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `Name` | The data source name. This is how you refer to the data source in panels and queries. | -| `Default` | Default data source means that it will be pre-selected for new panels. | -| `Url` | The HTTP protocol, IP, and port of your Elasticsearch server. | -| `Access` | Server (default) = URL needs to be accessible from the Grafana backend/server, Browser = URL needs to be accessible from the browser. **Note**: Browser (direct) access is deprecated and will be removed in a future release. | - -Access mode controls how requests to the data source will be handled. Server should be the preferred way if nothing else stated. - -### Server access mode (Default) - -All requests will be made from the browser to Grafana backend/server which in turn will forward the requests to the data source and by that circumvent possible Cross-Origin Resource Sharing (CORS) requirements. The URL needs to be accessible from the grafana backend/server if you select this access mode. - -### Browser (Direct) access - -> **Warning:** Browser (Direct) access is deprecated and will be removed in a future release. - -All requests will be made from the browser directly to the data source and may be subject to Cross-Origin Resource Sharing (CORS) requirements. The URL needs to be accessible from the browser if you select this access mode. - -If you select Browser access you must update your Elasticsearch configuration to allow other domains to access -Elasticsearch from the browser. You do this by specifying these two options in your **elasticsearch.yml** config file. - -```bash -http.cors.enabled: true -http.cors.allow-origin: "*" -``` +| Name | Description | +| --------- | --------------------------------------------------------------------------------- | +| `Name` | Data source name. This is how you refer to the data source in panels and queries. | +| `Default` | Data source is pre-selected for new panels. | +| `Url` | The HTTP protocol, IP, and port of your Elasticsearch server. | +| `Access` | Do not use Access. Use "Server (default)" or the datasource won't function. | ### Index settings diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx index c9ed7c53e29..20a16e1ecf7 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx @@ -32,8 +32,8 @@ export const ConfigEditor = (props: Props) => { return ( <> {options.access === 'direct' && ( - - Browser access mode in the Elasticsearch datasource is deprecated and will be removed in a future release. + + Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode. )} {!supportedVersion && ( diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index af4cc347a48..b829002e1cb 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -88,6 +88,7 @@ export class ElasticDatasource dataLinks: DataLinkConfig[]; languageProvider: LanguageProvider; includeFrozen: boolean; + isProxyAccess: boolean; constructor( instanceSettings: DataSourceInstanceSettings, @@ -99,6 +100,7 @@ export class ElasticDatasource this.url = instanceSettings.url!; this.name = instanceSettings.name; this.index = instanceSettings.database ?? ''; + this.isProxyAccess = instanceSettings.access === 'proxy'; const settingsData = instanceSettings.jsonData || ({} as ElasticsearchOptions); this.timeField = settingsData.timeField; @@ -132,6 +134,13 @@ export class ElasticDatasource data?: undefined, headers?: BackendSrvRequest['headers'] ): Observable { + if (!this.isProxyAccess) { + const error = new Error( + 'Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode.' + ); + return throwError(() => error); + } + if (!isSupportedVersion(this.esVersion)) { const error = new Error( 'Support for Elasticsearch versions after their end-of-life (currently versions < 7.10) was removed.'