Elasticsearch: Remove browser access mode (#49014)

* elastic: remove browser-access-mode

* improved text

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* improved text

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* better text

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* better text

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* better text

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* prettier fixes

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
pull/49141/head
Gábor Farkas 3 years ago committed by GitHub
parent 1d18b5ccd3
commit 45d6d38183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      docs/sources/datasources/elasticsearch.md
  2. 4
      public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx
  3. 9
      public/app/plugins/datasource/elasticsearch/datasource.ts

@ -26,31 +26,11 @@ 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. |
| --------- | --------------------------------------------------------------------------------- |
| `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` | 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: "*"
```
| `Access` | Do not use Access. Use "Server (default)" or the datasource won't function. |
### Index settings

@ -32,8 +32,8 @@ export const ConfigEditor = (props: Props) => {
return (
<>
{options.access === 'direct' && (
<Alert title="Deprecation Notice" severity="warning">
Browser access mode in the Elasticsearch datasource is deprecated and will be removed in a future release.
<Alert title="Error" severity="error">
Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode.
</Alert>
)}
{!supportedVersion && (

@ -88,6 +88,7 @@ export class ElasticDatasource
dataLinks: DataLinkConfig[];
languageProvider: LanguageProvider;
includeFrozen: boolean;
isProxyAccess: boolean;
constructor(
instanceSettings: DataSourceInstanceSettings<ElasticsearchOptions>,
@ -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<any> {
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.'

Loading…
Cancel
Save