Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into issue-108387-es-c…
Browse files Browse the repository at this point in the history
…lient-80
  • Loading branch information
pgayvallet committed Oct 25, 2021
2 parents 3b0d634 + 436c74a commit 8e71e3d
Show file tree
Hide file tree
Showing 149 changed files with 988 additions and 924 deletions.
4 changes: 0 additions & 4 deletions config/kibana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
# The URLs of the Elasticsearch instances to use for all your queries.
#elasticsearch.hosts: ["http://localhost:9200"]

# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"

# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) &gt; [getKibanaIndex](./kibana-plugin-core-server.savedobjectsservicesetup.getkibanaindex.md)

## SavedObjectsServiceSetup.getKibanaIndex property

Returns the default index used for saved objects.

<b>Signature:</b>

```typescript
getKibanaIndex: () => string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class Plugin() {
| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-core-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-core-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [getKibanaIndex](./kibana-plugin-core-server.savedobjectsservicesetup.getkibanaindex.md) | <code>() =&gt; string</code> | Returns the default index used for saved objects. |
| [registerType](./kibana-plugin-core-server.savedobjectsservicesetup.registertype.md) | <code>&lt;Attributes = any&gt;(type: SavedObjectsType&lt;Attributes&gt;) =&gt; void</code> | Register a [savedObjects type](./kibana-plugin-core-server.savedobjectstype.md) definition.<!-- -->See the [mappings format](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-core-server.savedobjectmigrationmap.md) for more details about these. |
| [setClientFactoryProvider](./kibana-plugin-core-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-core-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

```typescript
export declare type SharedGlobalConfig = RecursiveReadonly<{
kibana: Pick<KibanaConfigType, typeof SharedGlobalConfigKeys.kibana[number]>;
elasticsearch: Pick<ElasticsearchConfigType, typeof SharedGlobalConfigKeys.elasticsearch[number]>;
path: Pick<PathConfigType, typeof SharedGlobalConfigKeys.path[number]>;
savedObjects: Pick<SavedObjectsConfigType, typeof SharedGlobalConfigKeys.savedObjects[number]>;
Expand Down
12 changes: 0 additions & 12 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,6 @@ is an alternative to `elasticsearch.username` and `elasticsearch.password`.
| `interpreter.enableInVisualize`
| Enables use of interpreter in Visualize. *Default: `true`*

|[[kibana-index]] `kibana.index:`
| deprecated:[7.11.0,This setting will be removed in 8.0.] Multitenancy by
changing `kibana.index` will not be supported starting in 8.0. See
https://ela.st/kbn-remove-legacy-multitenancy[8.0 Breaking Changes] for more
details.
+
{kib} uses an index in {es} to store saved searches, visualizations, and
dashboards. {kib} creates a new index if the index doesn’t already exist. If
you configure a custom index, the name must be lowercase, and conform to the
{es} {ref}/indices-create-index.html[index name limitations].
*Default: `".kibana"`*

| `data.autocomplete.valueSuggestions.timeout:` {ess-icon}
| Time in milliseconds to wait for autocomplete suggestions from {es}.
This value must be a whole number greater than zero. *Default: `"1000"`*
Expand Down
4 changes: 2 additions & 2 deletions docs/setup/upgrade/upgrade-migrations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ WARNING: The following instructions assumes {kib} is using the default index nam

Saved objects are stored in two indices:

* `.kibana_{kibana_version}_001`, or if the `kibana.index` configuration setting is set `.{kibana.index}_{kibana_version}_001`. E.g. for Kibana v7.12.0 `.kibana_7.12.0_001`.
* `.kibana_task_manager_{kibana_version}_001`, or if the `xpack.tasks.index` configuration setting is set `.{xpack.tasks.index}_{kibana_version}_001` E.g. for Kibana v7.12.0 `.kibana_task_manager_7.12.0_001`.
* `.kibana_{kibana_version}_001`, e.g. for Kibana v7.12.0 `.kibana_7.12.0_001`.
* `.kibana_task_manager_{kibana_version}_001`, e.g. for Kibana v7.12.0 `.kibana_task_manager_7.12.0_001`.

The index aliases `.kibana` and `.kibana_task_manager` will always point to
the most up-to-date saved object indices.
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pageLoadAssetSize:
expressionShape: 34008
interactiveSetup: 80000
expressionTagcloud: 27505
securitySolution: 231753
securitySolution: 273763
customIntegrations: 28810
expressionMetricVis: 23121
visTypeMetric: 23332
Expand Down
1 change: 0 additions & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import { Action } from 'history';
import Boom from '@hapi/boom';
import { ConfigDeprecationProvider } from '@kbn/config';
import { ConfigPath } from '@kbn/config';
import { DetailedPeerCertificate } from 'tls';
import { EnvironmentMode } from '@kbn/config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { mockCoreContext } from '../core_context.mock';
import { config as RawElasticsearchConfig } from '../elasticsearch/elasticsearch_config';
import { config as RawHttpConfig } from '../http/http_config';
import { config as RawLoggingConfig } from '../logging/logging_config';
import { config as RawKibanaConfig } from '../kibana_config';
import { savedObjectsConfig as RawSavedObjectsConfig } from '../saved_objects/saved_objects_config';
import { httpServiceMock } from '../http/http_service.mock';
import { metricsServiceMock } from '../metrics/metrics_service.mock';
Expand All @@ -40,8 +39,6 @@ describe('CoreUsageDataService', () => {
return new BehaviorSubject(RawLoggingConfig.schema.validate({}));
} else if (path === 'savedObjects') {
return new BehaviorSubject(RawSavedObjectsConfig.schema.validate({}));
} else if (path === 'kibana') {
return new BehaviorSubject(RawKibanaConfig.schema.validate({}));
}
return new BehaviorSubject({});
};
Expand Down
34 changes: 7 additions & 27 deletions src/core/server/core_usage_data/core_usage_data_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type {
} from './types';
import { isConfigured } from './is_configured';
import { ElasticsearchServiceStart } from '../elasticsearch';
import { KibanaConfigType } from '../kibana_config';
import { coreUsageStatsType } from './core_usage_stats';
import { LEGACY_URL_ALIAS_TYPE } from '../saved_objects/object_types';
import { CORE_USAGE_STATS_TYPE } from './constants';
Expand All @@ -56,6 +55,8 @@ export interface StartDeps {
exposedConfigsToUsage: ExposedConfigsToUsage;
}

const kibanaIndex = '.kibana';

/**
* Because users can configure their Saved Object to any arbitrary index name,
* we need to map customized index names back to a "standard" index name.
Expand All @@ -74,19 +75,6 @@ const kibanaOrTaskManagerIndex = (index: string, kibanaConfigIndex: string) => {
return index === kibanaConfigIndex ? '.kibana' : '.kibana_task_manager';
};

/**
* This is incredibly hacky... The config service doesn't allow you to determine
* whether or not a config value has been changed from the default value, and the
* default value is defined in legacy code.
*
* This will be going away in 8.0, so please look away for a few months
*
* @param index The `kibana.index` setting from the `kibana.yml`
*/
const isCustomIndex = (index: string) => {
return index !== '.kibana';
};

export class CoreUsageDataService
implements CoreService<InternalCoreUsageDataSetup, CoreUsageDataStart>
{
Expand All @@ -98,7 +86,6 @@ export class CoreUsageDataService
private soConfig?: SavedObjectsConfigType;
private stop$: Subject<void>;
private opsMetrics?: OpsMetrics;
private kibanaConfig?: KibanaConfigType;
private coreUsageStatsClient?: CoreUsageStatsClient;
private deprecatedConfigPaths: ChangedDeprecatedPaths = { set: [], unset: [] };
private incrementUsageCounter: CoreIncrementUsageCounter = () => {}; // Initially set to noop
Expand Down Expand Up @@ -133,8 +120,8 @@ export class CoreUsageDataService
.getTypeRegistry()
.getAllTypes()
.reduce((acc, type) => {
const index = type.indexPattern ?? this.kibanaConfig!.index;
return index != null ? acc.add(index) : acc;
const index = type.indexPattern ?? kibanaIndex;
return acc.add(index);
}, new Set<string>())
.values()
).map((index) => {
Expand All @@ -150,7 +137,7 @@ export class CoreUsageDataService
.then(({ body }) => {
const stats = body[0];
return {
alias: kibanaOrTaskManagerIndex(index, this.kibanaConfig!.index),
alias: kibanaOrTaskManagerIndex(index, kibanaIndex),
docsCount: stats['docs.count'] ? parseInt(stats['docs.count'], 10) : 0,
docsDeleted: stats['docs.deleted'] ? parseInt(stats['docs.deleted'], 10) : 0,
storeSizeBytes: stats['store.size'] ? parseInt(stats['store.size'], 10) : 0,
Expand All @@ -167,7 +154,7 @@ export class CoreUsageDataService
// Note: this agg can be changed to use `savedObjectsRepository.find` in the future after `filters` is supported.
// See src/core/server/saved_objects/service/lib/aggregations/aggs_types/bucket_aggs.ts for supported aggregations.
const { body: resp } = await elasticsearch.client.asInternalUser.search({
index: this.kibanaConfig!.index,
index: kibanaIndex,
body: {
track_total_hits: true,
query: { match: { type: LEGACY_URL_ALIAS_TYPE } },
Expand Down Expand Up @@ -313,7 +300,7 @@ export class CoreUsageDataService
},

savedObjects: {
customIndex: isCustomIndex(this.kibanaConfig!.index),
customIndex: false,
maxImportPayloadBytes: this.soConfig.maxImportPayloadBytes.getValueInBytes(),
maxImportExportSize: this.soConfig.maxImportExportSize,
},
Expand Down Expand Up @@ -472,13 +459,6 @@ export class CoreUsageDataService
this.soConfig = config;
});

this.configService
.atPath<KibanaConfigType>('kibana')
.pipe(takeUntil(this.stop$))
.subscribe((config) => {
this.kibanaConfig = config;
});

changedDeprecatedConfigPath$
.pipe(takeUntil(this.stop$))
.subscribe((deprecatedConfigPaths) => (this.deprecatedConfigPaths = deprecatedConfigPaths));
Expand Down
42 changes: 0 additions & 42 deletions src/core/server/kibana_config.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions src/core/server/kibana_config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ type MockedPluginInitializerConfig<T> = jest.Mocked<PluginInitializerContext<T>[

export function pluginInitializerContextConfigMock<T>(config: T) {
const globalConfig: SharedGlobalConfig = {
kibana: {
index: '.kibana-tests',
},
elasticsearch: {
shardTimeout: duration('30s'),
requestTimeout: duration('30s'),
Expand Down
6 changes: 0 additions & 6 deletions src/core/server/plugins/legacy_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ describe('Legacy config', () => {
const legacyConfig = getGlobalConfig(configService);

expect(legacyConfig).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand All @@ -62,9 +59,6 @@ describe('Legacy config', () => {
const legacyConfig = await getGlobalConfig$(configService).pipe(take(1)).toPromise();

expect(legacyConfig).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand Down
9 changes: 1 addition & 8 deletions src/core/server/plugins/legacy_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@ import { pick, deepFreeze } from '@kbn/std';
import { IConfigService } from '@kbn/config';

import { SharedGlobalConfig, SharedGlobalConfigKeys } from './types';
import { KibanaConfigType, config as kibanaConfig } from '../kibana_config';
import {
ElasticsearchConfigType,
config as elasticsearchConfig,
} from '../elasticsearch/elasticsearch_config';
import { SavedObjectsConfigType, savedObjectsConfig } from '../saved_objects/saved_objects_config';

const createGlobalConfig = ({
kibana,
elasticsearch,
path,
savedObjects,
}: {
kibana: KibanaConfigType;
elasticsearch: ElasticsearchConfigType;
path: PathConfigType;
savedObjects: SavedObjectsConfigType;
}): SharedGlobalConfig => {
return deepFreeze({
kibana: pick(kibana, SharedGlobalConfigKeys.kibana),
elasticsearch: pick(elasticsearch, SharedGlobalConfigKeys.elasticsearch),
path: pick(path, SharedGlobalConfigKeys.path),
savedObjects: pick(savedObjects, SharedGlobalConfigKeys.savedObjects),
Expand All @@ -41,7 +37,6 @@ const createGlobalConfig = ({

export const getGlobalConfig = (configService: IConfigService): SharedGlobalConfig => {
return createGlobalConfig({
kibana: configService.atPathSync<KibanaConfigType>(kibanaConfig.path),
elasticsearch: configService.atPathSync<ElasticsearchConfigType>(elasticsearchConfig.path),
path: configService.atPathSync<PathConfigType>(pathConfig.path),
savedObjects: configService.atPathSync<SavedObjectsConfigType>(savedObjectsConfig.path),
Expand All @@ -50,15 +45,13 @@ export const getGlobalConfig = (configService: IConfigService): SharedGlobalConf

export const getGlobalConfig$ = (configService: IConfigService): Observable<SharedGlobalConfig> => {
return combineLatest([
configService.atPath<KibanaConfigType>(kibanaConfig.path),
configService.atPath<ElasticsearchConfigType>(elasticsearchConfig.path),
configService.atPath<PathConfigType>(pathConfig.path),
configService.atPath<SavedObjectsConfigType>(savedObjectsConfig.path),
]).pipe(
map(
([kibana, elasticsearch, path, savedObjects]) =>
([elasticsearch, path, savedObjects]) =>
createGlobalConfig({
kibana,
elasticsearch,
path,
savedObjects,
Expand Down
3 changes: 0 additions & 3 deletions src/core/server/plugins/plugin_context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ describe('createPluginInitializerContext', () => {
.pipe(first())
.toPromise();
expect(configObject).toStrictEqual({
kibana: {
index: '.kibana',
},
elasticsearch: {
shardTimeout: duration(30, 's'),
requestTimeout: duration(30, 's'),
Expand Down
1 change: 1 addition & 0 deletions src/core/server/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
addClientWrapper: deps.savedObjects.addClientWrapper,
registerType: deps.savedObjects.registerType,
getKibanaIndex: deps.savedObjects.getKibanaIndex,
},
status: {
core$: deps.status.core$,
Expand Down
Loading

0 comments on commit 8e71e3d

Please sign in to comment.