mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Allow to enable compression for communications with ES (#124009)
* Allow to enable compression for communications with ES * update generated doc * fix types in test * update another snapshot
This commit is contained in:
parent
4c826f22ca
commit
1eea7a32d4
12 changed files with 51 additions and 3 deletions
|
@ -62,6 +62,10 @@
|
||||||
# must be a positive integer.
|
# must be a positive integer.
|
||||||
#elasticsearch.requestTimeout: 30000
|
#elasticsearch.requestTimeout: 30000
|
||||||
|
|
||||||
|
# Specifies whether Kibana should use compression for communications with elasticsearch
|
||||||
|
# Defaults to `false`.
|
||||||
|
#elasticsearch.compression: false
|
||||||
|
|
||||||
# List of Kibana client-side headers to send to Elasticsearch. To send *no* client-side
|
# List of Kibana client-side headers to send to Elasticsearch. To send *no* client-side
|
||||||
# headers, set this value to [] (an empty list).
|
# headers, set this value to [] (an empty list).
|
||||||
#elasticsearch.requestHeadersWhitelist: [ authorization ]
|
#elasticsearch.requestHeadersWhitelist: [ authorization ]
|
||||||
|
|
|
@ -9,7 +9,7 @@ Configuration options to be used to create a [cluster client](./kibana-plugin-co
|
||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export declare type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders' | 'sniffOnStart' | 'sniffOnConnectionFault' | 'requestHeadersWhitelist' | 'sniffInterval' | 'hosts' | 'username' | 'password' | 'serviceAccountToken'> & {
|
export declare type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders' | 'compression' | 'sniffOnStart' | 'sniffOnConnectionFault' | 'requestHeadersWhitelist' | 'sniffInterval' | 'hosts' | 'username' | 'password' | 'serviceAccountToken'> & {
|
||||||
pingTimeout?: ElasticsearchConfig['pingTimeout'] | ClientOptions['pingTimeout'];
|
pingTimeout?: ElasticsearchConfig['pingTimeout'] | ClientOptions['pingTimeout'];
|
||||||
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
||||||
ssl?: Partial<ElasticsearchConfig['ssl']>;
|
ssl?: Partial<ElasticsearchConfig['ssl']>;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchConfig](./kibana-plugin-core-server.elasticsearchconfig.md) > [compression](./kibana-plugin-core-server.elasticsearchconfig.compression.md)
|
||||||
|
|
||||||
|
## ElasticsearchConfig.compression property
|
||||||
|
|
||||||
|
Whether to use compression for communications with elasticsearch.
|
||||||
|
|
||||||
|
<b>Signature:</b>
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
readonly compression: boolean;
|
||||||
|
```
|
|
@ -23,6 +23,7 @@ export declare class ElasticsearchConfig
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [apiVersion](./kibana-plugin-core-server.elasticsearchconfig.apiversion.md) | | string | Version of the Elasticsearch (6.7, 7.1 or <code>master</code>) client will be connecting to. |
|
| [apiVersion](./kibana-plugin-core-server.elasticsearchconfig.apiversion.md) | | string | Version of the Elasticsearch (6.7, 7.1 or <code>master</code>) client will be connecting to. |
|
||||||
|
| [compression](./kibana-plugin-core-server.elasticsearchconfig.compression.md) | | boolean | Whether to use compression for communications with elasticsearch. |
|
||||||
| [customHeaders](./kibana-plugin-core-server.elasticsearchconfig.customheaders.md) | | ElasticsearchConfigType\['customHeaders'\] | Header names and values to send to Elasticsearch with every request. These headers cannot be overwritten by client-side headers and aren't affected by <code>requestHeadersWhitelist</code> configuration. |
|
| [customHeaders](./kibana-plugin-core-server.elasticsearchconfig.customheaders.md) | | ElasticsearchConfigType\['customHeaders'\] | Header names and values to send to Elasticsearch with every request. These headers cannot be overwritten by client-side headers and aren't affected by <code>requestHeadersWhitelist</code> configuration. |
|
||||||
| [healthCheckDelay](./kibana-plugin-core-server.elasticsearchconfig.healthcheckdelay.md) | | Duration | The interval between health check requests Kibana sends to the Elasticsearch. |
|
| [healthCheckDelay](./kibana-plugin-core-server.elasticsearchconfig.healthcheckdelay.md) | | Duration | The interval between health check requests Kibana sends to the Elasticsearch. |
|
||||||
| [hosts](./kibana-plugin-core-server.elasticsearchconfig.hosts.md) | | string\[\] | Hosts that the client will connect to. If sniffing is enabled, this list will be used as seeds to discover the rest of your cluster. |
|
| [hosts](./kibana-plugin-core-server.elasticsearchconfig.hosts.md) | | string\[\] | Hosts that the client will connect to. If sniffing is enabled, this list will be used as seeds to discover the rest of your cluster. |
|
||||||
|
|
|
@ -152,6 +152,9 @@ This value must be a positive integer. *Default: `30000`*
|
||||||
| Time in milliseconds for {es} to wait for responses from shards.
|
| Time in milliseconds for {es} to wait for responses from shards.
|
||||||
Set to 0 to disable. *Default: `30000`*
|
Set to 0 to disable. *Default: `30000`*
|
||||||
|
|
||||||
|
| `elasticsearch.compression:`
|
||||||
|
| Specifies whether {kib} should use compression for communications with {es}. *Default: `false`*
|
||||||
|
|
||||||
| `elasticsearch.sniffInterval:`
|
| `elasticsearch.sniffInterval:`
|
||||||
| Time in milliseconds between requests to check {es} for an updated list of
|
| Time in milliseconds between requests to check {es} for an updated list of
|
||||||
nodes. *Default: `false`*
|
nodes. *Default: `false`*
|
||||||
|
|
|
@ -15,6 +15,7 @@ const createConfig = (
|
||||||
): ElasticsearchClientConfig => {
|
): ElasticsearchClientConfig => {
|
||||||
return {
|
return {
|
||||||
customHeaders: {},
|
customHeaders: {},
|
||||||
|
compression: false,
|
||||||
sniffOnStart: false,
|
sniffOnStart: false,
|
||||||
sniffOnConnectionFault: false,
|
sniffOnConnectionFault: false,
|
||||||
sniffInterval: false,
|
sniffInterval: false,
|
||||||
|
@ -89,7 +90,7 @@ describe('parseClientOptions', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('`keepAlive option`', () => {
|
describe('`keepAlive` option', () => {
|
||||||
it('`keepAlive` is true', () => {
|
it('`keepAlive` is true', () => {
|
||||||
const options = parseClientOptions(createConfig({ keepAlive: true }), false);
|
const options = parseClientOptions(createConfig({ keepAlive: true }), false);
|
||||||
expect(options.agent).toHaveProperty('keepAlive', true);
|
expect(options.agent).toHaveProperty('keepAlive', true);
|
||||||
|
@ -106,6 +107,18 @@ describe('parseClientOptions', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('`compression` option', () => {
|
||||||
|
it('`compression` is true', () => {
|
||||||
|
const options = parseClientOptions(createConfig({ compression: true }), false);
|
||||||
|
expect(options.compression).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('`compression` is false', () => {
|
||||||
|
const options = parseClientOptions(createConfig({ compression: false }), false);
|
||||||
|
expect(options.compression).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('`sniffOnStart` options', () => {
|
it('`sniffOnStart` options', () => {
|
||||||
expect(
|
expect(
|
||||||
parseClientOptions(
|
parseClientOptions(
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { DEFAULT_HEADERS } from '../default_headers';
|
||||||
export type ElasticsearchClientConfig = Pick<
|
export type ElasticsearchClientConfig = Pick<
|
||||||
ElasticsearchConfig,
|
ElasticsearchConfig,
|
||||||
| 'customHeaders'
|
| 'customHeaders'
|
||||||
|
| 'compression'
|
||||||
| 'sniffOnStart'
|
| 'sniffOnStart'
|
||||||
| 'sniffOnConnectionFault'
|
| 'sniffOnConnectionFault'
|
||||||
| 'requestHeadersWhitelist'
|
| 'requestHeadersWhitelist'
|
||||||
|
@ -63,6 +64,7 @@ export function parseClientOptions(
|
||||||
maxSockets: Infinity,
|
maxSockets: Infinity,
|
||||||
keepAlive: config.keepAlive ?? true,
|
keepAlive: config.keepAlive ?? true,
|
||||||
},
|
},
|
||||||
|
compression: config.compression,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (config.pingTimeout != null) {
|
if (config.pingTimeout != null) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ const createConfig = (
|
||||||
sniffOnStart: false,
|
sniffOnStart: false,
|
||||||
sniffOnConnectionFault: false,
|
sniffOnConnectionFault: false,
|
||||||
sniffInterval: false,
|
sniffInterval: false,
|
||||||
|
compression: false,
|
||||||
requestHeadersWhitelist: ['authorization'],
|
requestHeadersWhitelist: ['authorization'],
|
||||||
customHeaders: {},
|
customHeaders: {},
|
||||||
hosts: ['http://localhost'],
|
hosts: ['http://localhost'],
|
||||||
|
|
|
@ -29,6 +29,7 @@ test('set correct defaults', () => {
|
||||||
expect(configValue).toMatchInlineSnapshot(`
|
expect(configValue).toMatchInlineSnapshot(`
|
||||||
ElasticsearchConfig {
|
ElasticsearchConfig {
|
||||||
"apiVersion": "master",
|
"apiVersion": "master",
|
||||||
|
"compression": false,
|
||||||
"customHeaders": Object {},
|
"customHeaders": Object {},
|
||||||
"healthCheckDelay": "PT2.5S",
|
"healthCheckDelay": "PT2.5S",
|
||||||
"hosts": Array [
|
"hosts": Array [
|
||||||
|
|
|
@ -36,6 +36,7 @@ export const configSchema = schema.object({
|
||||||
hosts: schema.oneOf([hostURISchema, schema.arrayOf(hostURISchema, { minSize: 1 })], {
|
hosts: schema.oneOf([hostURISchema, schema.arrayOf(hostURISchema, { minSize: 1 })], {
|
||||||
defaultValue: 'http://localhost:9200',
|
defaultValue: 'http://localhost:9200',
|
||||||
}),
|
}),
|
||||||
|
compression: schema.boolean({ defaultValue: false }),
|
||||||
username: schema.maybe(
|
username: schema.maybe(
|
||||||
schema.string({
|
schema.string({
|
||||||
validate: (rawConfig) => {
|
validate: (rawConfig) => {
|
||||||
|
@ -297,6 +298,11 @@ export class ElasticsearchConfig {
|
||||||
*/
|
*/
|
||||||
public readonly apiVersion: string;
|
public readonly apiVersion: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to use compression for communications with elasticsearch.
|
||||||
|
*/
|
||||||
|
public readonly compression: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hosts that the client will connect to. If sniffing is enabled, this list will
|
* Hosts that the client will connect to. If sniffing is enabled, this list will
|
||||||
* be used as seeds to discover the rest of your cluster.
|
* be used as seeds to discover the rest of your cluster.
|
||||||
|
@ -399,6 +405,7 @@ export class ElasticsearchConfig {
|
||||||
this.password = rawConfig.password;
|
this.password = rawConfig.password;
|
||||||
this.serviceAccountToken = rawConfig.serviceAccountToken;
|
this.serviceAccountToken = rawConfig.serviceAccountToken;
|
||||||
this.customHeaders = rawConfig.customHeaders;
|
this.customHeaders = rawConfig.customHeaders;
|
||||||
|
this.compression = rawConfig.compression;
|
||||||
this.skipStartupConnectionCheck = rawConfig.skipStartupConnectionCheck;
|
this.skipStartupConnectionCheck = rawConfig.skipStartupConnectionCheck;
|
||||||
|
|
||||||
const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
|
const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
|
||||||
|
|
|
@ -232,6 +232,7 @@ export const config: {
|
||||||
sniffInterval: Type<false | Duration>;
|
sniffInterval: Type<false | Duration>;
|
||||||
sniffOnConnectionFault: Type<boolean>;
|
sniffOnConnectionFault: Type<boolean>;
|
||||||
hosts: Type<string | string[]>;
|
hosts: Type<string | string[]>;
|
||||||
|
compression: Type<boolean>;
|
||||||
username: Type<string | undefined>;
|
username: Type<string | undefined>;
|
||||||
password: Type<string | undefined>;
|
password: Type<string | undefined>;
|
||||||
serviceAccountToken: Type<string | undefined>;
|
serviceAccountToken: Type<string | undefined>;
|
||||||
|
@ -878,7 +879,7 @@ export type ElasticsearchClient = Omit<KibanaClient, 'connectionPool' | 'transpo
|
||||||
};
|
};
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
export type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders' | 'sniffOnStart' | 'sniffOnConnectionFault' | 'requestHeadersWhitelist' | 'sniffInterval' | 'hosts' | 'username' | 'password' | 'serviceAccountToken'> & {
|
export type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders' | 'compression' | 'sniffOnStart' | 'sniffOnConnectionFault' | 'requestHeadersWhitelist' | 'sniffInterval' | 'hosts' | 'username' | 'password' | 'serviceAccountToken'> & {
|
||||||
pingTimeout?: ElasticsearchConfig['pingTimeout'] | ClientOptions['pingTimeout'];
|
pingTimeout?: ElasticsearchConfig['pingTimeout'] | ClientOptions['pingTimeout'];
|
||||||
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
||||||
ssl?: Partial<ElasticsearchConfig['ssl']>;
|
ssl?: Partial<ElasticsearchConfig['ssl']>;
|
||||||
|
@ -890,6 +891,7 @@ export type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders
|
||||||
export class ElasticsearchConfig {
|
export class ElasticsearchConfig {
|
||||||
constructor(rawConfig: ElasticsearchConfigType);
|
constructor(rawConfig: ElasticsearchConfigType);
|
||||||
readonly apiVersion: string;
|
readonly apiVersion: string;
|
||||||
|
readonly compression: boolean;
|
||||||
// Warning: (ae-forgotten-export) The symbol "ElasticsearchConfigType" needs to be exported by the entry point index.d.ts
|
// Warning: (ae-forgotten-export) The symbol "ElasticsearchConfigType" needs to be exported by the entry point index.d.ts
|
||||||
readonly customHeaders: ElasticsearchConfigType['customHeaders'];
|
readonly customHeaders: ElasticsearchConfigType['customHeaders'];
|
||||||
readonly healthCheckDelay: Duration;
|
readonly healthCheckDelay: Duration;
|
||||||
|
|
|
@ -70,6 +70,7 @@ describe('config schema', () => {
|
||||||
"debug_mode": false,
|
"debug_mode": false,
|
||||||
"elasticsearch": Object {
|
"elasticsearch": Object {
|
||||||
"apiVersion": "master",
|
"apiVersion": "master",
|
||||||
|
"compression": false,
|
||||||
"customHeaders": Object {},
|
"customHeaders": Object {},
|
||||||
"healthCheck": Object {
|
"healthCheck": Object {
|
||||||
"delay": "PT2.5S",
|
"delay": "PT2.5S",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue