-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Usage counters] Relocate counters to a dedicated index. Unify / simplify 'ui' and 'server' counters logic. #187064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f94e8a
f1eca22
b9a828f
c656fb3
1c226c6
6c91c98
fff9e1c
a273eb1
b7a2d54
b28d019
c61df3b
aed12b4
6c7a6cf
f0fe90c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,7 @@ describe('migration v2 - CHECK_TARGET_MAPPINGS', () => { | |
|
|
||
| // Check for migration steps present in the logs | ||
| logs = await fs.readFile(logFilePath, 'utf-8'); | ||
| expect(logs).not.toMatch('CREATE_NEW_TARGET'); | ||
| expect(logs).not.toMatch('[.kibana] CREATE_NEW_TARGET'); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test now creates a new index for the new type. |
||
| expect(logs).toMatch('CHECK_TARGET_MAPPINGS -> UPDATE_TARGET_MAPPINGS_PROPERTIES'); | ||
| expect(logs).toMatch( | ||
| 'UPDATE_TARGET_MAPPINGS_PROPERTIES -> UPDATE_TARGET_MAPPINGS_PROPERTIES_WAIT_FOR_TASK' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,135 +173,15 @@ describe('split .kibana index into multiple system indices', () => { | |
| }) | ||
| ); | ||
|
|
||
| expect(indicesInfo[`.kibana_${currentVersion}_001`].mappings?._meta?.indexTypesMap) | ||
| .toMatchInlineSnapshot(` | ||
| Object { | ||
| ".kibana": Array [ | ||
| "action", | ||
| "action_task_params", | ||
| "ad_hoc_run_params", | ||
| "alert", | ||
| "api_key_pending_invalidation", | ||
| "apm-custom-dashboards", | ||
| "apm-indices", | ||
| "apm-server-schema", | ||
| "apm-service-group", | ||
| "apm-telemetry", | ||
| "app_search_telemetry", | ||
| "application_usage_daily", | ||
| "application_usage_totals", | ||
| "canvas-element", | ||
| "canvas-workpad-template", | ||
| "cases", | ||
| "cases-comments", | ||
| "cases-configure", | ||
| "cases-connector-mappings", | ||
| "cases-rules", | ||
| "cases-telemetry", | ||
| "cases-user-actions", | ||
| "cloud-security-posture-settings", | ||
| "config", | ||
| "config-global", | ||
| "connector_token", | ||
| "core-usage-stats", | ||
| "csp-rule-template", | ||
| "endpoint:unified-user-artifact-manifest", | ||
| "endpoint:user-artifact-manifest", | ||
| "enterprise_search_telemetry", | ||
| "entity-definition", | ||
| "entity-discovery-api-key", | ||
| "epm-packages", | ||
| "epm-packages-assets", | ||
| "event-annotation-group", | ||
| "event_loop_delays_daily", | ||
| "exception-list", | ||
| "exception-list-agnostic", | ||
| "file", | ||
| "file-upload-usage-collection-telemetry", | ||
| "fileShare", | ||
| "fleet-fleet-server-host", | ||
| "fleet-message-signing-keys", | ||
| "fleet-preconfiguration-deletion-record", | ||
| "fleet-proxy", | ||
| "fleet-setup-lock", | ||
| "fleet-uninstall-tokens", | ||
| "graph-workspace", | ||
| "guided-onboarding-guide-state", | ||
| "guided-onboarding-plugin-state", | ||
| "index-pattern", | ||
| "infra-custom-dashboards", | ||
| "infrastructure-monitoring-log-view", | ||
| "infrastructure-ui-source", | ||
| "ingest-agent-policies", | ||
| "ingest-download-sources", | ||
| "ingest-outputs", | ||
| "ingest-package-policies", | ||
| "ingest_manager_settings", | ||
| "inventory-view", | ||
| "kql-telemetry", | ||
| "legacy-url-alias", | ||
| "lens", | ||
| "lens-ui-telemetry", | ||
| "links", | ||
| "maintenance-window", | ||
| "map", | ||
| "metrics-data-source", | ||
| "metrics-explorer-view", | ||
| "ml-job", | ||
| "ml-module", | ||
| "ml-trained-model", | ||
| "monitoring-telemetry", | ||
| "observability-onboarding-state", | ||
| "osquery-manager-usage-metric", | ||
| "osquery-pack", | ||
| "osquery-pack-asset", | ||
| "osquery-saved-query", | ||
| "policy-settings-protection-updates-note", | ||
| "query", | ||
| "risk-engine-configuration", | ||
| "rules-settings", | ||
| "sample-data-telemetry", | ||
| "search-session", | ||
| "search-telemetry", | ||
| "security-rule", | ||
| "security-solution-signals-migration", | ||
| "siem-detection-engine-rule-actions", | ||
| "siem-ui-timeline", | ||
| "siem-ui-timeline-note", | ||
| "siem-ui-timeline-pinned-event", | ||
| "slo", | ||
| "slo-settings", | ||
| "space", | ||
| "spaces-usage-stats", | ||
| "synthetics-dynamic-settings", | ||
| "synthetics-monitor", | ||
| "synthetics-param", | ||
| "synthetics-privates-locations", | ||
| "tag", | ||
| "telemetry", | ||
| "threshold-explorer-view", | ||
| "ui-metric", | ||
| "upgrade-assistant-ml-upgrade-operation", | ||
| "upgrade-assistant-reindex-operation", | ||
| "uptime-dynamic-settings", | ||
| "uptime-synthetics-api-key", | ||
| "url", | ||
| "usage-counters", | ||
| "workplace_search_telemetry", | ||
| ], | ||
| ".kibana_so_search": Array [ | ||
| "search", | ||
| ], | ||
| ".kibana_so_ui": Array [ | ||
| "canvas-workpad", | ||
| "dashboard", | ||
| "visualization", | ||
| ], | ||
| ".kibana_task_manager": Array [ | ||
| "task", | ||
| ], | ||
| } | ||
| `); | ||
| const typesMap = indicesInfo[`.kibana_${currentVersion}_001`].mappings?._meta?.indexTypesMap; | ||
|
|
||
| expect(Array.isArray(typesMap['.kibana'])).toEqual(true); | ||
| expect(typesMap['.kibana'].length > 50).toEqual(true); | ||
| expect(typesMap['.kibana'].includes('action')).toEqual(true); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking that the map contains an exhaustive list of mappings is not necessary. |
||
| expect(typesMap['.kibana'].includes('cases')).toEqual(true); | ||
| expect(typesMap['.kibana_so_search']).toEqual(['search']); | ||
| expect(typesMap['.kibana_so_ui']).toEqual(['canvas-workpad', 'dashboard', 'visualization']); | ||
| expect(typesMap['.kibana_task_manager']).toEqual(['task']); | ||
|
|
||
| const logs = await parseLogFile(logFilePathFirstRun); | ||
|
|
||
|
|
@@ -506,6 +386,7 @@ describe('split .kibana index into multiple system indices', () => { | |
| '.kibana_task_manager': { | ||
| task: 5, | ||
| }, | ||
| '.kibana_usage_counters': {}, | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import Hapi from '@hapi/hapi'; | ||
| import h2o2 from '@hapi/h2o2'; | ||
| import { URL } from 'url'; | ||
| import { SavedObject, ALL_SAVED_OBJECT_INDICES } from '@kbn/core-saved-objects-server'; | ||
| import type { SavedObject } from '@kbn/core-saved-objects-server'; | ||
| import type { ISavedObjectsRepository } from '@kbn/core-saved-objects-api-server'; | ||
| import type { InternalCoreSetup, InternalCoreStart } from '@kbn/core-lifecycle-server-internal'; | ||
| import { Root } from '@kbn/core-root-server-internal'; | ||
|
|
@@ -18,7 +18,6 @@ import { | |
| createTestServers, | ||
| type TestElasticsearchUtils, | ||
| } from '@kbn/core-test-helpers-kbn-server'; | ||
| import { kibanaPackageJson as pkg } from '@kbn/repo-info'; | ||
| import { | ||
| declareGetRoute, | ||
| declareDeleteRoute, | ||
|
|
@@ -32,7 +31,8 @@ import { | |
| declarePassthroughRoute, | ||
| declareIndexRoute, | ||
| setProxyInterrupt, | ||
| allCombinationsPermutations, | ||
| getVersionedKibanaIndex, | ||
| getIndicesWithNamespaceAwareTypes, | ||
| } from './repository_with_proxy_utils'; | ||
|
|
||
| let esServer: TestElasticsearchUtils; | ||
|
|
@@ -93,29 +93,40 @@ describe('404s from proxies', () => { | |
| ? parseInt(process.env.TEST_PROXY_SERVER_PORT, 10) | ||
| : 5698; | ||
|
|
||
| // Setup kibana configured to use proxy as ES backend | ||
| root = createRootWithCorePlugins({ | ||
| elasticsearch: { | ||
| hosts: [`http://${esHostname}:${proxyPort}`], | ||
| }, | ||
| migrations: { | ||
| skip: false, | ||
| }, | ||
| }); | ||
| await root.preboot(); | ||
| const setup = await root.setup(); | ||
| registerSOTypes(setup); | ||
|
|
||
| // Setup custom hapi hapiServer with h2o2 plugin for proxying | ||
| hapiServer = Hapi.server({ | ||
| port: proxyPort, | ||
| }); | ||
|
|
||
| const mainIndex = getVersionedKibanaIndex(); | ||
| await hapiServer.register(h2o2); | ||
| // register specific routes to modify the response and a catch-all to relay the request/response as-is | ||
| declareGetRoute(hapiServer, esHostname, esPort, mainIndex); | ||
| declareDeleteRoute(hapiServer, esHostname, esPort, mainIndex); | ||
| declarePostUpdateRoute(hapiServer, esHostname, esPort, mainIndex); | ||
|
|
||
| allCombinationsPermutations( | ||
| ALL_SAVED_OBJECT_INDICES.map((indexPattern) => `${indexPattern}_${pkg.version}`) | ||
| ) | ||
| .map((indices) => indices.join(',')) | ||
| .forEach((kbnIndexPath) => { | ||
| declareGetRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declareDeleteRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declarePostUpdateRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
|
|
||
| declareGetSearchRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declarePostSearchRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declarePostPitRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declarePostUpdateByQueryRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| declareIndexRoute(hapiServer, esHostname, esPort, kbnIndexPath); | ||
| }); | ||
| declareGetSearchRoute(hapiServer, esHostname, esPort, mainIndex); | ||
| declarePostSearchRoute(hapiServer, esHostname, esPort, mainIndex); | ||
| declarePostPitRoute(hapiServer, esHostname, esPort, mainIndex); | ||
| declareIndexRoute(hapiServer, esHostname, esPort, mainIndex); | ||
|
|
||
| // the deleteByNamespace performs an updateByQuery under the hood. | ||
| // It targets all SO indices that have namespace-aware types | ||
| const nsIndices = getIndicesWithNamespaceAwareTypes(setup.savedObjects.getTypeRegistry()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we were running a very costly operation, registering thousands of routes, when 99% of requests target |
||
| declarePostUpdateByQueryRoute(hapiServer, esHostname, esPort, nsIndices); | ||
|
|
||
| // register index-agnostic routes | ||
| declarePostBulkRoute(hapiServer, esHostname, esPort); | ||
|
|
@@ -124,19 +135,6 @@ describe('404s from proxies', () => { | |
|
|
||
| await hapiServer.start(); | ||
|
|
||
| // Setup kibana configured to use proxy as ES backend | ||
| root = createRootWithCorePlugins({ | ||
| elasticsearch: { | ||
| hosts: [`http://${esHostname}:${proxyPort}`], | ||
| }, | ||
| migrations: { | ||
| skip: false, | ||
| }, | ||
| }); | ||
| await root.preboot(); | ||
| const setup = await root.setup(); | ||
| registerSOTypes(setup); | ||
|
|
||
| start = await root.start(); | ||
| }); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧡