mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -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.
|
||||
#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
|
||||
# headers, set this value to [] (an empty list).
|
||||
#elasticsearch.requestHeadersWhitelist: [ authorization ]
|
||||
|
|
|
@ -9,7 +9,7 @@ Configuration options to be used to create a [cluster client](./kibana-plugin-co
|
|||
<b>Signature:</b>
|
||||
|
||||
```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'];
|
||||
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
||||
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 |
|
||||
| --- | --- | --- | --- |
|
||||
| [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. |
|
||||
| [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. |
|
||||
|
|
|
@ -152,6 +152,9 @@ This value must be a positive integer. *Default: `30000`*
|
|||
| Time in milliseconds for {es} to wait for responses from shards.
|
||||
Set to 0 to disable. *Default: `30000`*
|
||||
|
||||
| `elasticsearch.compression:`
|
||||
| Specifies whether {kib} should use compression for communications with {es}. *Default: `false`*
|
||||
|
||||
| `elasticsearch.sniffInterval:`
|
||||
| Time in milliseconds between requests to check {es} for an updated list of
|
||||
nodes. *Default: `false`*
|
||||
|
|
|
@ -15,6 +15,7 @@ const createConfig = (
|
|||
): ElasticsearchClientConfig => {
|
||||
return {
|
||||
customHeaders: {},
|
||||
compression: false,
|
||||
sniffOnStart: false,
|
||||
sniffOnConnectionFault: false,
|
||||
sniffInterval: false,
|
||||
|
@ -89,7 +90,7 @@ describe('parseClientOptions', () => {
|
|||
);
|
||||
});
|
||||
|
||||
describe('`keepAlive option`', () => {
|
||||
describe('`keepAlive` option', () => {
|
||||
it('`keepAlive` is true', () => {
|
||||
const options = parseClientOptions(createConfig({ keepAlive: true }), false);
|
||||
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', () => {
|
||||
expect(
|
||||
parseClientOptions(
|
||||
|
|
|
@ -22,6 +22,7 @@ import { DEFAULT_HEADERS } from '../default_headers';
|
|||
export type ElasticsearchClientConfig = Pick<
|
||||
ElasticsearchConfig,
|
||||
| 'customHeaders'
|
||||
| 'compression'
|
||||
| 'sniffOnStart'
|
||||
| 'sniffOnConnectionFault'
|
||||
| 'requestHeadersWhitelist'
|
||||
|
@ -63,6 +64,7 @@ export function parseClientOptions(
|
|||
maxSockets: Infinity,
|
||||
keepAlive: config.keepAlive ?? true,
|
||||
},
|
||||
compression: config.compression,
|
||||
};
|
||||
|
||||
if (config.pingTimeout != null) {
|
||||
|
|
|
@ -26,6 +26,7 @@ const createConfig = (
|
|||
sniffOnStart: false,
|
||||
sniffOnConnectionFault: false,
|
||||
sniffInterval: false,
|
||||
compression: false,
|
||||
requestHeadersWhitelist: ['authorization'],
|
||||
customHeaders: {},
|
||||
hosts: ['http://localhost'],
|
||||
|
|
|
@ -29,6 +29,7 @@ test('set correct defaults', () => {
|
|||
expect(configValue).toMatchInlineSnapshot(`
|
||||
ElasticsearchConfig {
|
||||
"apiVersion": "master",
|
||||
"compression": false,
|
||||
"customHeaders": Object {},
|
||||
"healthCheckDelay": "PT2.5S",
|
||||
"hosts": Array [
|
||||
|
|
|
@ -36,6 +36,7 @@ export const configSchema = schema.object({
|
|||
hosts: schema.oneOf([hostURISchema, schema.arrayOf(hostURISchema, { minSize: 1 })], {
|
||||
defaultValue: 'http://localhost:9200',
|
||||
}),
|
||||
compression: schema.boolean({ defaultValue: false }),
|
||||
username: schema.maybe(
|
||||
schema.string({
|
||||
validate: (rawConfig) => {
|
||||
|
@ -297,6 +298,11 @@ export class ElasticsearchConfig {
|
|||
*/
|
||||
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
|
||||
* be used as seeds to discover the rest of your cluster.
|
||||
|
@ -399,6 +405,7 @@ export class ElasticsearchConfig {
|
|||
this.password = rawConfig.password;
|
||||
this.serviceAccountToken = rawConfig.serviceAccountToken;
|
||||
this.customHeaders = rawConfig.customHeaders;
|
||||
this.compression = rawConfig.compression;
|
||||
this.skipStartupConnectionCheck = rawConfig.skipStartupConnectionCheck;
|
||||
|
||||
const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
|
||||
|
|
|
@ -232,6 +232,7 @@ export const config: {
|
|||
sniffInterval: Type<false | Duration>;
|
||||
sniffOnConnectionFault: Type<boolean>;
|
||||
hosts: Type<string | string[]>;
|
||||
compression: Type<boolean>;
|
||||
username: Type<string | undefined>;
|
||||
password: Type<string | undefined>;
|
||||
serviceAccountToken: Type<string | undefined>;
|
||||
|
@ -878,7 +879,7 @@ export type ElasticsearchClient = Omit<KibanaClient, 'connectionPool' | 'transpo
|
|||
};
|
||||
|
||||
// @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'];
|
||||
requestTimeout?: ElasticsearchConfig['requestTimeout'] | ClientOptions['requestTimeout'];
|
||||
ssl?: Partial<ElasticsearchConfig['ssl']>;
|
||||
|
@ -890,6 +891,7 @@ export type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders
|
|||
export class ElasticsearchConfig {
|
||||
constructor(rawConfig: ElasticsearchConfigType);
|
||||
readonly apiVersion: string;
|
||||
readonly compression: boolean;
|
||||
// Warning: (ae-forgotten-export) The symbol "ElasticsearchConfigType" needs to be exported by the entry point index.d.ts
|
||||
readonly customHeaders: ElasticsearchConfigType['customHeaders'];
|
||||
readonly healthCheckDelay: Duration;
|
||||
|
|
|
@ -70,6 +70,7 @@ describe('config schema', () => {
|
|||
"debug_mode": false,
|
||||
"elasticsearch": Object {
|
||||
"apiVersion": "master",
|
||||
"compression": false,
|
||||
"customHeaders": Object {},
|
||||
"healthCheck": Object {
|
||||
"delay": "PT2.5S",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue