mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Ingest] Make all saved objects namespace agnostic, move to NP plugin (#64360)
* Move saved object type registration & mapping to NP plugin; normalize and prefix saved object type names * Replace hardcoded saved object type names with constants * Adjust output type name * Review and import fixes * Update tests, fixtures, and instructions
This commit is contained in:
parent
a00051f914
commit
74bf87721f
37 changed files with 381 additions and 305 deletions
|
@ -4,43 +4,10 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { resolve } from 'path';
|
||||
import {
|
||||
savedObjectMappings,
|
||||
OUTPUT_SAVED_OBJECT_TYPE,
|
||||
AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
DATASOURCE_SAVED_OBJECT_TYPE,
|
||||
PACKAGES_SAVED_OBJECT_TYPE,
|
||||
} from '../../../plugins/ingest_manager/server';
|
||||
|
||||
// TODO https://github.com/elastic/kibana/issues/46373
|
||||
// const INDEX_NAMES = {
|
||||
// INGEST: '.kibana',
|
||||
// };
|
||||
|
||||
export function ingestManager(kibana: any) {
|
||||
return new kibana.Plugin({
|
||||
id: 'ingestManager',
|
||||
publicDir: resolve(__dirname, '../../../plugins/ingest_manager/public'),
|
||||
uiExports: {
|
||||
savedObjectSchemas: {
|
||||
[AGENT_CONFIG_SAVED_OBJECT_TYPE]: {
|
||||
isNamespaceAgnostic: true,
|
||||
// indexPattern: INDEX_NAMES.INGEST,
|
||||
},
|
||||
[OUTPUT_SAVED_OBJECT_TYPE]: {
|
||||
isNamespaceAgnostic: true,
|
||||
// indexPattern: INDEX_NAMES.INGEST,
|
||||
},
|
||||
[DATASOURCE_SAVED_OBJECT_TYPE]: {
|
||||
isNamespaceAgnostic: true,
|
||||
// indexPattern: INDEX_NAMES.INGEST,
|
||||
},
|
||||
[PACKAGES_SAVED_OBJECT_TYPE]: {
|
||||
isNamespaceAgnostic: true,
|
||||
// indexPattern: INDEX_NAMES.INGEST,
|
||||
},
|
||||
},
|
||||
mappings: savedObjectMappings,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,60 +1,70 @@
|
|||
# Ingest Manager
|
||||
|
||||
## Plugin
|
||||
- The plugin is disabled by default. See the TypeScript type for the [the available plugin configuration options](https://github.com/elastic/kibana/blob/master/x-pack/plugins/ingest_manager/common/types/index.ts#L9-L27)
|
||||
- Setting `xpack.ingestManager.enabled=true` enables the plugin including the EPM and Fleet features. It also adds the `DATASOURCE_API_ROUTES` and `AGENT_CONFIG_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts)
|
||||
- Adding `--xpack.ingestManager.epm.enabled=false` will disable the EPM API & UI
|
||||
- Adding `--xpack.ingestManager.fleet.enabled=false` will disable the Fleet API & UI
|
||||
- [code for adding the routes](https://github.com/elastic/kibana/blob/1f27d349533b1c2865c10c45b2cf705d7416fb36/x-pack/plugins/ingest_manager/server/plugin.ts#L115-L133)
|
||||
- [Integration tests](server/integration_tests/router.test.ts)
|
||||
- Both EPM and Fleet require `ingestManager` be enabled. They are not standalone features.
|
||||
|
||||
- The plugin is disabled by default. See the TypeScript type for the [the available plugin configuration options](https://github.com/elastic/kibana/blob/master/x-pack/plugins/ingest_manager/common/types/index.ts#L9-L27)
|
||||
- Setting `xpack.ingestManager.enabled=true` enables the plugin including the EPM and Fleet features. It also adds the `DATASOURCE_API_ROUTES` and `AGENT_CONFIG_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts)
|
||||
- Adding `--xpack.ingestManager.epm.enabled=false` will disable the EPM API & UI
|
||||
- Adding `--xpack.ingestManager.fleet.enabled=false` will disable the Fleet API & UI
|
||||
- [code for adding the routes](https://github.com/elastic/kibana/blob/1f27d349533b1c2865c10c45b2cf705d7416fb36/x-pack/plugins/ingest_manager/server/plugin.ts#L115-L133)
|
||||
- [Integration tests](server/integration_tests/router.test.ts)
|
||||
- Both EPM and Fleet require `ingestManager` be enabled. They are not standalone features.
|
||||
|
||||
## Development
|
||||
|
||||
### Getting started
|
||||
|
||||
See the Kibana docs for [how to set up your dev environment](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#setting-up-your-development-environment), [run Elasticsearch](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#running-elasticsearch), and [start Kibana](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#running-kibana)
|
||||
|
||||
|
||||
One common development workflow is:
|
||||
- Bootstrap Kibana
|
||||
```
|
||||
yarn kbn bootstrap
|
||||
```
|
||||
- Start Elasticsearch in one shell
|
||||
```
|
||||
yarn es snapshot -E xpack.security.authc.api_key.enabled=true
|
||||
```
|
||||
- Start Kibana in another shell
|
||||
```
|
||||
yarn start --xpack.ingestManager.enabled=true --no-base-path --xpack.endpoint.enabled=true
|
||||
```
|
||||
|
||||
- Bootstrap Kibana
|
||||
```
|
||||
yarn kbn bootstrap
|
||||
```
|
||||
- Start Elasticsearch in one shell
|
||||
```
|
||||
yarn es snapshot -E xpack.security.authc.api_key.enabled=true
|
||||
```
|
||||
- Start Kibana in another shell
|
||||
```
|
||||
yarn start --xpack.ingestManager.enabled=true --no-base-path --xpack.endpoint.enabled=true
|
||||
```
|
||||
|
||||
This plugin follows the `common`, `server`, `public` structure from the [Architecture Style Guide
|
||||
](https://github.com/elastic/kibana/blob/master/style_guides/architecture_style_guide.md#file-and-folder-structure). We also follow the pattern of developing feature branches under your personal fork of Kibana.
|
||||
|
||||
### API Tests
|
||||
|
||||
#### Ingest & Fleet
|
||||
1. In one terminal, change to the `x-pack` directory and start the test server with
|
||||
```
|
||||
node scripts/functional_tests_server.js --config test/api_integration/config.ts
|
||||
```
|
||||
|
||||
1. in a second terminal, run the tests from the Kibana root directory with
|
||||
```
|
||||
node scripts/functional_test_runner.js --config x-pack/test/api_integration/config.ts
|
||||
```
|
||||
1. In one terminal, change to the `x-pack` directory and start the test server with
|
||||
|
||||
```
|
||||
node scripts/functional_tests_server.js --config test/api_integration/config.js
|
||||
```
|
||||
|
||||
1. in a second terminal, run the tests from the Kibana root directory with
|
||||
```
|
||||
node scripts/functional_test_runner.js --config x-pack/test/api_integration/config.js
|
||||
```
|
||||
|
||||
#### EPM
|
||||
1. In one terminal, change to the `x-pack` directory and start the test server with
|
||||
```
|
||||
node scripts/functional_tests_server.js --config test/epm_api_integration/config.ts
|
||||
```
|
||||
|
||||
1. in a second terminal, run the tests from the Kibana root directory with
|
||||
```
|
||||
node scripts/functional_test_runner.js --config x-pack/test/epm_api_integration/config.ts
|
||||
```
|
||||
1. In one terminal, change to the `x-pack` directory and start the test server with
|
||||
|
||||
### Staying up-to-date with `master`
|
||||
While we're developing in the `feature-ingest` feature branch, here's is more information on keeping up to date with upstream kibana.
|
||||
```
|
||||
node scripts/functional_tests_server.js --config test/epm_api_integration/config.ts
|
||||
```
|
||||
|
||||
1. in a second terminal, run the tests from the Kibana root directory with
|
||||
```
|
||||
node scripts/functional_test_runner.js --config x-pack/test/epm_api_integration/config.ts
|
||||
```
|
||||
|
||||
### Staying up-to-date with `master`
|
||||
|
||||
While we're developing in the `feature-ingest` feature branch, here's is more information on keeping up to date with upstream kibana.
|
||||
|
||||
<details>
|
||||
<summary>merge upstream <code>master</code> into <code>feature-ingest</code></summary>
|
||||
|
@ -80,6 +90,7 @@ git push origin
|
|||
## push your changes to upstream feature branch from the terminal; not GitHub UI
|
||||
git push upstream
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
See https://github.com/elastic/kibana/pull/37950 for an example.
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const AGENT_SAVED_OBJECT_TYPE = 'agents';
|
||||
export const AGENT_EVENT_SAVED_OBJECT_TYPE = 'agent_events';
|
||||
export const AGENT_ACTION_SAVED_OBJECT_TYPE = 'agent_actions';
|
||||
export const AGENT_SAVED_OBJECT_TYPE = 'fleet-agents';
|
||||
export const AGENT_EVENT_SAVED_OBJECT_TYPE = 'fleet-agent-events';
|
||||
export const AGENT_ACTION_SAVED_OBJECT_TYPE = 'fleet-agent-actions';
|
||||
|
||||
export const AGENT_TYPE_PERMANENT = 'PERMANENT';
|
||||
export const AGENT_TYPE_EPHEMERAL = 'EPHEMERAL';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { AgentConfigStatus, DefaultPackages } from '../types';
|
||||
|
||||
export const AGENT_CONFIG_SAVED_OBJECT_TYPE = 'agent_configs';
|
||||
export const AGENT_CONFIG_SAVED_OBJECT_TYPE = 'ingest-agent-configs';
|
||||
|
||||
export const DEFAULT_AGENT_CONFIG = {
|
||||
name: 'Default config',
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const DATASOURCE_SAVED_OBJECT_TYPE = 'datasources';
|
||||
export const DATASOURCE_SAVED_OBJECT_TYPE = 'ingest-datasources';
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE = 'enrollment_api_keys';
|
||||
export const ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE = 'fleet-enrollment-api-keys';
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const PACKAGES_SAVED_OBJECT_TYPE = 'epm-package';
|
||||
export const PACKAGES_SAVED_OBJECT_TYPE = 'epm-packages';
|
||||
export const INDEX_PATTERN_SAVED_OBJECT_TYPE = 'index-pattern';
|
||||
export const DEFAULT_REGISTRY_URL = 'https://epr.elastic.co';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { OutputType } from '../types';
|
||||
|
||||
export const OUTPUT_SAVED_OBJECT_TYPE = 'outputs';
|
||||
export const OUTPUT_SAVED_OBJECT_TYPE = 'ingest-outputs';
|
||||
|
||||
export const DEFAULT_OUTPUT = {
|
||||
name: 'default',
|
||||
|
|
|
@ -8,20 +8,22 @@ import {
|
|||
AGENT_TYPE_TEMPORARY,
|
||||
AGENT_POLLING_THRESHOLD_MS,
|
||||
AGENT_TYPE_PERMANENT,
|
||||
AGENT_SAVED_OBJECT_TYPE,
|
||||
} from '../constants';
|
||||
|
||||
export function buildKueryForOnlineAgents() {
|
||||
return `agents.last_checkin >= now-${(3 * AGENT_POLLING_THRESHOLD_MS) / 1000}s`;
|
||||
return `${AGENT_SAVED_OBJECT_TYPE}.last_checkin >= now-${(3 * AGENT_POLLING_THRESHOLD_MS) /
|
||||
1000}s`;
|
||||
}
|
||||
|
||||
export function buildKueryForOfflineAgents() {
|
||||
return `agents.type:${AGENT_TYPE_TEMPORARY} AND agents.last_checkin < now-${(3 *
|
||||
return `${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_TEMPORARY} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${(3 *
|
||||
AGENT_POLLING_THRESHOLD_MS) /
|
||||
1000}s`;
|
||||
}
|
||||
|
||||
export function buildKueryForErrorAgents() {
|
||||
return `agents.type:${AGENT_TYPE_PERMANENT} AND agents.last_checkin < now-${(4 *
|
||||
return `${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${(4 *
|
||||
AGENT_POLLING_THRESHOLD_MS) /
|
||||
1000}s`;
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
## Example
|
||||
|
||||
```js
|
||||
GET /api/ingest_manager/fleet/agents?kuery=agents.last_checkin:2019-10-01T13:42:54.323Z
|
||||
GET /api/ingest_manager/fleet/agents?kuery=fleet-agents.last_checkin:2019-10-01T13:42:54.323Z
|
||||
```
|
||||
|
|
|
@ -8,12 +8,11 @@ import React, { useState, useEffect } from 'react';
|
|||
import { IFieldType } from 'src/plugins/data/public';
|
||||
// @ts-ignore
|
||||
import { EuiSuggest, EuiSuggestItemProps } from '@elastic/eui';
|
||||
import { useDebounce } from '../hooks';
|
||||
import { useStartDeps } from '../hooks/use_deps';
|
||||
import { INDEX_NAME } from '../constants';
|
||||
import { useDebounce, useStartDeps } from '../hooks';
|
||||
import { INDEX_NAME, AGENT_SAVED_OBJECT_TYPE } from '../constants';
|
||||
|
||||
const DEBOUNCE_SEARCH_MS = 150;
|
||||
const HIDDEN_FIELDS = ['agents.actions'];
|
||||
const HIDDEN_FIELDS = [`${AGENT_SAVED_OBJECT_TYPE}.actions`];
|
||||
|
||||
interface Suggestion {
|
||||
label: string;
|
||||
|
|
|
@ -3,7 +3,16 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
export { PLUGIN_ID, EPM_API_ROUTES, AGENT_CONFIG_SAVED_OBJECT_TYPE } from '../../../../common';
|
||||
export {
|
||||
PLUGIN_ID,
|
||||
EPM_API_ROUTES,
|
||||
AGENT_API_ROUTES,
|
||||
AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
AGENT_EVENT_SAVED_OBJECT_TYPE,
|
||||
AGENT_SAVED_OBJECT_TYPE,
|
||||
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
|
||||
DATASOURCE_SAVED_OBJECT_TYPE,
|
||||
} from '../../../../common';
|
||||
|
||||
export const BASE_PATH = '/app/ingestManager';
|
||||
export const EPM_PATH = '/epm';
|
||||
|
|
|
@ -8,6 +8,7 @@ import React, { Fragment, useRef, useState } from 'react';
|
|||
import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { AGENT_SAVED_OBJECT_TYPE } from '../../../constants';
|
||||
import { sendDeleteAgentConfigs, useCore, sendRequest } from '../../../hooks';
|
||||
|
||||
interface Props {
|
||||
|
@ -122,7 +123,7 @@ export const AgentConfigDeleteProvider: React.FunctionComponent<Props> = ({ chil
|
|||
path: `/api/ingest_manager/fleet/agents`,
|
||||
method: 'get',
|
||||
query: {
|
||||
kuery: `agents.config_id : (${agentConfigsToCheck.join(' or ')})`,
|
||||
kuery: `${AGENT_SAVED_OBJECT_TYPE}.config_id : (${agentConfigsToCheck.join(' or ')})`,
|
||||
},
|
||||
});
|
||||
setAgentsCount(data?.total || 0);
|
||||
|
|
|
@ -9,8 +9,8 @@ import { EuiCallOut, EuiConfirmModal, EuiOverlayMask, EuiSpacer } from '@elastic
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { useCore, sendRequest, sendDeleteDatasource, useConfig } from '../../../hooks';
|
||||
import { AGENT_API_ROUTES } from '../../../../../../common/constants';
|
||||
import { AgentConfig } from '../../../../../../common/types/models';
|
||||
import { AGENT_API_ROUTES, AGENT_SAVED_OBJECT_TYPE } from '../../../constants';
|
||||
import { AgentConfig } from '../../../types';
|
||||
|
||||
interface Props {
|
||||
agentConfig: AgentConfig;
|
||||
|
@ -51,7 +51,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent<Props> = ({
|
|||
query: {
|
||||
page: 1,
|
||||
perPage: 1,
|
||||
kuery: `agents.config_id : ${agentConfig.id}`,
|
||||
kuery: `${AGENT_SAVED_OBJECT_TYPE}.config_id : ${agentConfig.id}`,
|
||||
},
|
||||
});
|
||||
setAgentsCount(data?.total || 0);
|
||||
|
|
|
@ -8,10 +8,11 @@ import React from 'react';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
|
||||
import { EuiSpacer } from '@elastic/eui';
|
||||
import { useGetPackageInstallStatus } from '../../hooks';
|
||||
import { InstallStatus, PackageInfo } from '../../../../types';
|
||||
import { InstallationButton } from './installation_button';
|
||||
import { useGetDatasources } from '../../../../hooks';
|
||||
import { DATASOURCE_SAVED_OBJECT_TYPE } from '../../../../constants';
|
||||
import { useGetPackageInstallStatus } from '../../hooks';
|
||||
import { InstallationButton } from './installation_button';
|
||||
|
||||
const NoteLabel = () => (
|
||||
<FormattedMessage
|
||||
|
@ -26,7 +27,7 @@ export const SettingsPanel = (
|
|||
const { data: datasourcesData } = useGetDatasources({
|
||||
perPage: 0,
|
||||
page: 1,
|
||||
kuery: `datasources.package.name:${props.name}`,
|
||||
kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name:${props.name}`,
|
||||
});
|
||||
const { name, title, removable } = props;
|
||||
const packageInstallStatus = getPackageInstallStatus(name);
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage, FormattedTime } from '@kbn/i18n/react';
|
||||
import { AGENT_EVENT_SAVED_OBJECT_TYPE } from '../../../../constants';
|
||||
import { Agent, AgentEvent } from '../../../../types';
|
||||
import { usePagination, useGetOneAgentEvents } from '../../../../hooks';
|
||||
import { SearchBar } from '../../../../components/search_bar';
|
||||
|
@ -130,7 +131,11 @@ export const AgentEventsTable: React.FunctionComponent<{ agent: Agent }> = ({ ag
|
|||
<EuiSpacer size="l" />
|
||||
<EuiFlexGroup>
|
||||
<EuiFlexItem>
|
||||
<SearchBar value={search} onChange={setSearch} fieldPrefix={'agent_events'} />
|
||||
<SearchBar
|
||||
value={search}
|
||||
onChange={setSearch}
|
||||
fieldPrefix={AGENT_EVENT_SAVED_OBJECT_TYPE}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={null}>
|
||||
<EuiButton color="secondary" iconType="refresh" onClick={onClickRefresh}>
|
||||
|
|
|
@ -40,7 +40,11 @@ import { SearchBar } from '../../../components/search_bar';
|
|||
import { AgentHealth } from '../components/agent_health';
|
||||
import { AgentUnenrollProvider } from '../components/agent_unenroll_provider';
|
||||
import { AgentStatusKueryHelper } from '../../../services';
|
||||
import { FLEET_AGENT_DETAIL_PATH, AGENT_CONFIG_DETAILS_PATH } from '../../../constants';
|
||||
import {
|
||||
FLEET_AGENT_DETAIL_PATH,
|
||||
AGENT_CONFIG_DETAILS_PATH,
|
||||
AGENT_SAVED_OBJECT_TYPE,
|
||||
} from '../../../constants';
|
||||
|
||||
const NO_WRAP_TRUNCATE_STYLE: CSSProperties = Object.freeze({
|
||||
overflow: 'hidden',
|
||||
|
@ -180,7 +184,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
|
|||
if (kuery) {
|
||||
kuery = `(${kuery}) and`;
|
||||
}
|
||||
kuery = `${kuery} agents.config_id : (${selectedConfigs
|
||||
kuery = `${kuery} ${AGENT_SAVED_OBJECT_TYPE}.config_id : (${selectedConfigs
|
||||
.map(config => `"${config}"`)
|
||||
.join(' or ')})`;
|
||||
}
|
||||
|
@ -394,7 +398,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
|
|||
});
|
||||
setSearch(newSearch);
|
||||
}}
|
||||
fieldPrefix="agents"
|
||||
fieldPrefix={AGENT_SAVED_OBJECT_TYPE}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={2}>
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import { FormattedMessage, FormattedDate } from '@kbn/i18n/react';
|
||||
import { ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE } from '../../../constants';
|
||||
import {
|
||||
usePagination,
|
||||
useGetEnrollmentAPIKeys,
|
||||
|
@ -29,7 +30,6 @@ import {
|
|||
import { EnrollmentAPIKey } from '../../../types';
|
||||
import { SearchBar } from '../../../components/search_bar';
|
||||
import { NewEnrollmentTokenFlyout } from './components/new_enrollment_key_flyout';
|
||||
import {} from '@elastic/eui';
|
||||
import { ConfirmEnrollmentTokenDelete } from './components/confirm_delete_modal';
|
||||
|
||||
const NO_WRAP_TRUNCATE_STYLE: CSSProperties = Object.freeze({
|
||||
|
@ -251,7 +251,7 @@ export const EnrollmentTokenListPage: React.FunctionComponent<{}> = () => {
|
|||
});
|
||||
setSearch(newSearch);
|
||||
}}
|
||||
fieldPrefix="enrollment_api_keys"
|
||||
fieldPrefix={ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
|
|
|
@ -43,13 +43,3 @@ export type IngestManagerConfigType = TypeOf<typeof config.schema>;
|
|||
export const plugin = (initializerContext: PluginInitializerContext) => {
|
||||
return new IngestManagerPlugin(initializerContext);
|
||||
};
|
||||
|
||||
// Saved object information bootstrapped by legacy `ingest_manager` plugin
|
||||
// TODO: Remove once saved object mappings can be done from NP
|
||||
export { savedObjectMappings } from './saved_objects';
|
||||
export {
|
||||
OUTPUT_SAVED_OBJECT_TYPE,
|
||||
AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
DATASOURCE_SAVED_OBJECT_TYPE,
|
||||
PACKAGES_SAVED_OBJECT_TYPE,
|
||||
} from './constants';
|
||||
|
|
|
@ -29,7 +29,7 @@ import {
|
|||
AGENT_EVENT_SAVED_OBJECT_TYPE,
|
||||
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
|
||||
} from './constants';
|
||||
import { registerEncryptedSavedObjects } from './saved_objects';
|
||||
import { registerSavedObjects, registerEncryptedSavedObjects } from './saved_objects';
|
||||
import {
|
||||
registerEPMRoutes,
|
||||
registerDatasourceRoutes,
|
||||
|
@ -109,6 +109,7 @@ export class IngestManagerPlugin
|
|||
this.security = deps.security;
|
||||
}
|
||||
|
||||
registerSavedObjects(core.savedObjects);
|
||||
registerEncryptedSavedObjects(deps.encryptedSavedObjects);
|
||||
|
||||
// Register feature
|
||||
|
|
|
@ -8,6 +8,7 @@ import { RequestHandler } from 'src/core/server';
|
|||
import bluebird from 'bluebird';
|
||||
import { appContextService, agentConfigService, datasourceService } from '../../services';
|
||||
import { listAgents } from '../../services/agents';
|
||||
import { AGENT_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import {
|
||||
GetAgentConfigsRequestSchema,
|
||||
GetOneAgentConfigRequestSchema,
|
||||
|
@ -50,7 +51,7 @@ export const getAgentConfigsHandler: RequestHandler<
|
|||
showInactive: true,
|
||||
perPage: 0,
|
||||
page: 1,
|
||||
kuery: `agents.config_id:${agentConfig.id}`,
|
||||
kuery: `${AGENT_SAVED_OBJECT_TYPE}.config_id:${agentConfig.id}`,
|
||||
}).then(({ total: agentTotal }) => (agentConfig.agents = agentTotal)),
|
||||
{ concurrency: 10 }
|
||||
);
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { SavedObjectsServiceSetup, SavedObjectsType } from 'kibana/server';
|
||||
import { EncryptedSavedObjectsPluginSetup } from '../../encrypted_saved_objects/server';
|
||||
import {
|
||||
OUTPUT_SAVED_OBJECT_TYPE,
|
||||
AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
|
@ -13,156 +16,225 @@ import {
|
|||
AGENT_ACTION_SAVED_OBJECT_TYPE,
|
||||
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
|
||||
} from './constants';
|
||||
import { EncryptedSavedObjectsPluginSetup } from '../../encrypted_saved_objects/server';
|
||||
|
||||
/*
|
||||
* Saved object mappings
|
||||
* Saved object types and mappings
|
||||
*
|
||||
* Please update typings in `/common/types` if mappings are updated.
|
||||
*/
|
||||
export const savedObjectMappings = {
|
||||
const savedObjectTypes: { [key: string]: SavedObjectsType } = {
|
||||
[AGENT_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
shared_id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
active: { type: 'boolean' },
|
||||
enrolled_at: { type: 'date' },
|
||||
access_api_key_id: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
user_provided_metadata: { type: 'text' },
|
||||
local_metadata: { type: 'text' },
|
||||
config_id: { type: 'keyword' },
|
||||
last_updated: { type: 'date' },
|
||||
last_checkin: { type: 'date' },
|
||||
config_revision: { type: 'integer' },
|
||||
config_newest_revision: { type: 'integer' },
|
||||
default_api_key_id: { type: 'keyword' },
|
||||
default_api_key: { type: 'keyword' },
|
||||
updated_at: { type: 'date' },
|
||||
current_error_events: { type: 'text' },
|
||||
name: AGENT_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
shared_id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
active: { type: 'boolean' },
|
||||
enrolled_at: { type: 'date' },
|
||||
access_api_key_id: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
user_provided_metadata: { type: 'text' },
|
||||
local_metadata: { type: 'text' },
|
||||
config_id: { type: 'keyword' },
|
||||
last_updated: { type: 'date' },
|
||||
last_checkin: { type: 'date' },
|
||||
config_revision: { type: 'integer' },
|
||||
config_newest_revision: { type: 'integer' },
|
||||
default_api_key_id: { type: 'keyword' },
|
||||
default_api_key: { type: 'keyword' },
|
||||
updated_at: { type: 'date' },
|
||||
current_error_events: { type: 'text' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[AGENT_ACTION_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
agent_id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
data: { type: 'binary' },
|
||||
sent_at: { type: 'date' },
|
||||
created_at: { type: 'date' },
|
||||
name: AGENT_ACTION_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
agent_id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
data: { type: 'binary' },
|
||||
sent_at: { type: 'date' },
|
||||
created_at: { type: 'date' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[AGENT_EVENT_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
type: { type: 'keyword' },
|
||||
subtype: { type: 'keyword' },
|
||||
agent_id: { type: 'keyword' },
|
||||
action_id: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
stream_id: { type: 'keyword' },
|
||||
timestamp: { type: 'date' },
|
||||
message: { type: 'text' },
|
||||
payload: { type: 'text' },
|
||||
data: { type: 'text' },
|
||||
name: AGENT_EVENT_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
type: { type: 'keyword' },
|
||||
subtype: { type: 'keyword' },
|
||||
agent_id: { type: 'keyword' },
|
||||
action_id: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
stream_id: { type: 'keyword' },
|
||||
timestamp: { type: 'date' },
|
||||
message: { type: 'text' },
|
||||
payload: { type: 'text' },
|
||||
data: { type: 'text' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[AGENT_CONFIG_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
name: { type: 'text' },
|
||||
is_default: { type: 'boolean' },
|
||||
namespace: { type: 'keyword' },
|
||||
description: { type: 'text' },
|
||||
status: { type: 'keyword' },
|
||||
datasources: { type: 'keyword' },
|
||||
updated_on: { type: 'keyword' },
|
||||
updated_by: { type: 'keyword' },
|
||||
revision: { type: 'integer' },
|
||||
name: AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
name: { type: 'text' },
|
||||
is_default: { type: 'boolean' },
|
||||
namespace: { type: 'keyword' },
|
||||
description: { type: 'text' },
|
||||
status: { type: 'keyword' },
|
||||
datasources: { type: 'keyword' },
|
||||
updated_on: { type: 'keyword' },
|
||||
updated_by: { type: 'keyword' },
|
||||
revision: { type: 'integer' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
api_key: { type: 'binary' },
|
||||
api_key_id: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
created_at: { type: 'date' },
|
||||
updated_at: { type: 'date' },
|
||||
expire_at: { type: 'date' },
|
||||
active: { type: 'boolean' },
|
||||
name: ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
api_key: { type: 'binary' },
|
||||
api_key_id: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
created_at: { type: 'date' },
|
||||
updated_at: { type: 'date' },
|
||||
expire_at: { type: 'date' },
|
||||
active: { type: 'boolean' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[OUTPUT_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
is_default: { type: 'boolean' },
|
||||
hosts: { type: 'keyword' },
|
||||
ca_sha256: { type: 'keyword' },
|
||||
fleet_enroll_username: { type: 'binary' },
|
||||
fleet_enroll_password: { type: 'binary' },
|
||||
config: { type: 'flattened' },
|
||||
name: OUTPUT_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
is_default: { type: 'boolean' },
|
||||
hosts: { type: 'keyword' },
|
||||
ca_sha256: { type: 'keyword' },
|
||||
fleet_enroll_username: { type: 'binary' },
|
||||
fleet_enroll_password: { type: 'binary' },
|
||||
config: { type: 'flattened' },
|
||||
},
|
||||
},
|
||||
},
|
||||
[DATASOURCE_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
description: { type: 'text' },
|
||||
namespace: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
package: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
title: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
name: DATASOURCE_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
description: { type: 'text' },
|
||||
namespace: { type: 'keyword' },
|
||||
config_id: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
package: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
title: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
},
|
||||
},
|
||||
},
|
||||
output_id: { type: 'keyword' },
|
||||
inputs: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
type: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
processors: { type: 'keyword' },
|
||||
config: { type: 'flattened' },
|
||||
streams: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
dataset: { type: 'keyword' },
|
||||
processors: { type: 'keyword' },
|
||||
config: { type: 'flattened' },
|
||||
pkg_stream: { type: 'flattened' },
|
||||
output_id: { type: 'keyword' },
|
||||
inputs: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
type: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
processors: { type: 'keyword' },
|
||||
config: { type: 'flattened' },
|
||||
streams: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
enabled: { type: 'boolean' },
|
||||
dataset: { type: 'keyword' },
|
||||
processors: { type: 'keyword' },
|
||||
config: { type: 'flattened' },
|
||||
pkg_stream: { type: 'flattened' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
revision: { type: 'integer' },
|
||||
},
|
||||
revision: { type: 'integer' },
|
||||
},
|
||||
},
|
||||
[PACKAGES_SAVED_OBJECT_TYPE]: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
internal: { type: 'boolean' },
|
||||
removable: { type: 'boolean' },
|
||||
es_index_patterns: {
|
||||
dynamic: false,
|
||||
type: 'object',
|
||||
},
|
||||
installed: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
name: PACKAGES_SAVED_OBJECT_TYPE,
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
management: {
|
||||
importableAndExportable: false,
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
name: { type: 'keyword' },
|
||||
version: { type: 'keyword' },
|
||||
internal: { type: 'boolean' },
|
||||
removable: { type: 'boolean' },
|
||||
es_index_patterns: {
|
||||
dynamic: 'false',
|
||||
type: 'object',
|
||||
},
|
||||
installed: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
id: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function registerSavedObjects(savedObjects: SavedObjectsServiceSetup) {
|
||||
Object.values(savedObjectTypes).forEach(type => {
|
||||
savedObjects.registerType(type);
|
||||
});
|
||||
}
|
||||
|
||||
export function registerEncryptedSavedObjects(
|
||||
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup
|
||||
) {
|
||||
|
|
|
@ -67,7 +67,7 @@ class AgentConfigService {
|
|||
public async ensureDefaultAgentConfig(soClient: SavedObjectsClientContract) {
|
||||
const configs = await soClient.find<AgentConfig>({
|
||||
type: AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
filter: 'agent_configs.attributes.is_default:true',
|
||||
filter: `${AGENT_CONFIG_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
|
||||
});
|
||||
|
||||
if (configs.total === 0) {
|
||||
|
@ -244,7 +244,7 @@ class AgentConfigService {
|
|||
public async getDefaultAgentConfigId(soClient: SavedObjectsClientContract) {
|
||||
const configs = await soClient.find({
|
||||
type: AGENT_CONFIG_SAVED_OBJECT_TYPE,
|
||||
filter: 'agent_configs.attributes.is_default:true',
|
||||
filter: `${AGENT_CONFIG_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
|
||||
});
|
||||
|
||||
if (configs.saved_objects.length === 0) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
AgentActionSOAttributes,
|
||||
AgentEvent,
|
||||
} from '../../../common/types/models';
|
||||
import { AGENT_TYPE_PERMANENT } from '../../../common/constants';
|
||||
import { AGENT_TYPE_PERMANENT, AGENT_ACTION_SAVED_OBJECT_TYPE } from '../../../common/constants';
|
||||
import { acknowledgeAgentActions } from './acks';
|
||||
import { appContextService } from '../app_context';
|
||||
import { IngestManagerAppContext } from '../../plugin';
|
||||
|
@ -31,7 +31,7 @@ describe('test agent acks services', () => {
|
|||
Promise.resolve({
|
||||
id: 'action1',
|
||||
references: [],
|
||||
type: 'agent_actions',
|
||||
type: AGENT_ACTION_SAVED_OBJECT_TYPE,
|
||||
attributes: {
|
||||
type: 'CONFIG_CHANGE',
|
||||
agent_id: 'id',
|
||||
|
@ -48,7 +48,7 @@ describe('test agent acks services', () => {
|
|||
{
|
||||
id: 'action1',
|
||||
references: [],
|
||||
type: 'agent_actions',
|
||||
type: AGENT_ACTION_SAVED_OBJECT_TYPE,
|
||||
attributes: {
|
||||
type: 'CONFIG_CHANGE',
|
||||
agent_id: 'id',
|
||||
|
@ -137,7 +137,7 @@ describe('test agent acks services', () => {
|
|||
{
|
||||
id: 'action1',
|
||||
references: [],
|
||||
type: 'agent_actions',
|
||||
type: AGENT_ACTION_SAVED_OBJECT_TYPE,
|
||||
attributes: {
|
||||
type: 'CONFIG_CHANGE',
|
||||
agent_id: 'id',
|
||||
|
|
|
@ -31,12 +31,17 @@ export async function listAgents(
|
|||
|
||||
if (kuery && kuery !== '') {
|
||||
// To ensure users dont need to know about SO data structure...
|
||||
filters.push(kuery.replace(/agents\./g, 'agents.attributes.'));
|
||||
filters.push(
|
||||
kuery.replace(
|
||||
new RegExp(`${AGENT_SAVED_OBJECT_TYPE}\.`, 'g'),
|
||||
`${AGENT_SAVED_OBJECT_TYPE}.attributes.`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (showInactive === false) {
|
||||
const agentActiveCondition = `agents.attributes.active:true AND not agents.attributes.type:${AGENT_TYPE_EPHEMERAL}`;
|
||||
const recentlySeenEphemeralAgent = `agents.attributes.active:true AND agents.attributes.type:${AGENT_TYPE_EPHEMERAL} AND agents.attributes.last_checkin > ${Date.now() -
|
||||
const agentActiveCondition = `${AGENT_SAVED_OBJECT_TYPE}.attributes.active:true AND not ${AGENT_SAVED_OBJECT_TYPE}.attributes.type:${AGENT_TYPE_EPHEMERAL}`;
|
||||
const recentlySeenEphemeralAgent = `${AGENT_SAVED_OBJECT_TYPE}.attributes.active:true AND ${AGENT_SAVED_OBJECT_TYPE}.attributes.type:${AGENT_TYPE_EPHEMERAL} AND ${AGENT_SAVED_OBJECT_TYPE}.attributes.last_checkin > ${Date.now() -
|
||||
3 * AGENT_POLLING_THRESHOLD_MS}`;
|
||||
filters.push(`(${agentActiveCondition}) OR (${recentlySeenEphemeralAgent})`);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,10 @@ export async function getAgentEvents(
|
|||
type: AGENT_EVENT_SAVED_OBJECT_TYPE,
|
||||
filter:
|
||||
kuery && kuery !== ''
|
||||
? kuery.replace(/agent_events\./g, 'agent_events.attributes.')
|
||||
? kuery.replace(
|
||||
new RegExp(`${AGENT_EVENT_SAVED_OBJECT_TYPE}\.`, 'g'),
|
||||
`${AGENT_EVENT_SAVED_OBJECT_TYPE}.attributes.`
|
||||
)
|
||||
: undefined,
|
||||
perPage,
|
||||
page,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { SavedObjectsClientContract } from 'src/core/server';
|
||||
import { getAgent, listAgents } from './crud';
|
||||
import { AGENT_EVENT_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import { AgentStatus, Agent } from '../../types';
|
||||
|
||||
import {
|
||||
|
@ -72,8 +72,8 @@ export async function getAgentStatusForConfig(
|
|||
page: 1,
|
||||
kuery: configId
|
||||
? kuery
|
||||
? `(${kuery}) and (agents.config_id:"${configId}")`
|
||||
: `agents.config_id:"${configId}"`
|
||||
? `(${kuery}) and (${AGENT_SAVED_OBJECT_TYPE}.config_id:"${configId}")`
|
||||
: `${AGENT_SAVED_OBJECT_TYPE}.config_id:"${configId}"`
|
||||
: kuery,
|
||||
})
|
||||
)
|
||||
|
@ -91,7 +91,9 @@ export async function getAgentStatusForConfig(
|
|||
async function getEventsCount(soClient: SavedObjectsClientContract, configId?: string) {
|
||||
const { total } = await soClient.find({
|
||||
type: AGENT_EVENT_SAVED_OBJECT_TYPE,
|
||||
filter: configId ? `agent_events.attributes.config_id:"${configId}"` : undefined,
|
||||
filter: configId
|
||||
? `${AGENT_EVENT_SAVED_OBJECT_TYPE}.attributes.config_id:"${configId}"`
|
||||
: undefined,
|
||||
perPage: 0,
|
||||
page: 1,
|
||||
sortField: 'timestamp',
|
||||
|
|
|
@ -22,7 +22,7 @@ export async function updateAgentsForConfigId(
|
|||
let page = 1;
|
||||
while (hasMore) {
|
||||
const { agents } = await listAgents(soClient, {
|
||||
kuery: `agents.config_id:"${configId}"`,
|
||||
kuery: `${AGENT_SAVED_OBJECT_TYPE}.config_id:"${configId}"`,
|
||||
page: page++,
|
||||
perPage: 1000,
|
||||
showInactive: true,
|
||||
|
@ -46,7 +46,7 @@ export async function unenrollForConfigId(soClient: SavedObjectsClientContract,
|
|||
let page = 1;
|
||||
while (hasMore) {
|
||||
const { agents } = await listAgents(soClient, {
|
||||
kuery: `agents.config_id:"${configId}"`,
|
||||
kuery: `${AGENT_SAVED_OBJECT_TYPE}.config_id:"${configId}"`,
|
||||
page: page++,
|
||||
perPage: 1000,
|
||||
showInactive: true,
|
||||
|
|
|
@ -31,7 +31,10 @@ export async function listEnrollmentApiKeys(
|
|||
sortOrder: 'DESC',
|
||||
filter:
|
||||
kuery && kuery !== ''
|
||||
? kuery.replace(/enrollment_api_keys\./g, 'enrollment_api_keys.attributes.')
|
||||
? kuery.replace(
|
||||
new RegExp(`${ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE}\.`, 'g'),
|
||||
`${ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE}.attributes.`
|
||||
)
|
||||
: undefined,
|
||||
});
|
||||
|
||||
|
@ -80,7 +83,7 @@ export async function deleteEnrollmentApiKeyForConfigId(
|
|||
const { items } = await listEnrollmentApiKeys(soClient, {
|
||||
page: page++,
|
||||
perPage: 100,
|
||||
kuery: `enrollment_api_keys.config_id:${configId}`,
|
||||
kuery: `${ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE}.config_id:${configId}`,
|
||||
});
|
||||
|
||||
if (items.length === 0) {
|
||||
|
|
|
@ -14,7 +14,7 @@ class OutputService {
|
|||
public async ensureDefaultOutput(soClient: SavedObjectsClientContract) {
|
||||
const outputs = await soClient.find<Output>({
|
||||
type: OUTPUT_SAVED_OBJECT_TYPE,
|
||||
filter: 'outputs.attributes.is_default:true',
|
||||
filter: `${OUTPUT_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
|
||||
});
|
||||
|
||||
if (!outputs.saved_objects.length) {
|
||||
|
@ -44,7 +44,7 @@ class OutputService {
|
|||
public async getDefaultOutputId(soClient: SavedObjectsClientContract) {
|
||||
const outputs = await soClient.find({
|
||||
type: OUTPUT_SAVED_OBJECT_TYPE,
|
||||
filter: 'outputs.attributes.is_default:true',
|
||||
filter: `${OUTPUT_SAVED_OBJECT_TYPE}.attributes.is_default:true`,
|
||||
});
|
||||
|
||||
if (!outputs.saved_objects.length) {
|
||||
|
|
|
@ -32,12 +32,12 @@ export default function(providerContext: FtrProviderContext) {
|
|||
body: { _source: agentDoc },
|
||||
} = await esClient.get({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
});
|
||||
agentDoc.agents.access_api_key_id = apiKey.id;
|
||||
agentDoc['fleet-agents'].access_api_key_id = apiKey.id;
|
||||
await esClient.update({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
refresh: 'true',
|
||||
body: {
|
||||
doc: agentDoc,
|
||||
|
|
|
@ -67,7 +67,7 @@ export default function(providerContext: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(404);
|
||||
expect(apiResponse.message).to.eql('Saved object [agents/agent100] not found');
|
||||
expect(apiResponse.message).to.eql('Saved object [fleet-agents/agent100] not found');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ export default function(providerContext: FtrProviderContext) {
|
|||
body: { _source: agentDoc },
|
||||
} = await esClient.get({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
});
|
||||
agentDoc.agents.access_api_key_id = apiKey.id;
|
||||
agentDoc['fleet-agents'].access_api_key_id = apiKey.id;
|
||||
await esClient.update({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
refresh: 'true',
|
||||
body: {
|
||||
doc: agentDoc,
|
||||
|
|
|
@ -33,13 +33,13 @@ export default function(providerContext: FtrProviderContext) {
|
|||
body: { _source: enrollmentApiKeyDoc },
|
||||
} = await esClient.get({
|
||||
index: '.kibana',
|
||||
id: 'enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0',
|
||||
id: 'fleet-enrollment-api-keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0',
|
||||
});
|
||||
// @ts-ignore
|
||||
enrollmentApiKeyDoc.enrollment_api_keys.api_key_id = apiKey.id;
|
||||
enrollmentApiKeyDoc['fleet-enrollment-api-keys'].api_key_id = apiKey.id;
|
||||
await esClient.update({
|
||||
index: '.kibana',
|
||||
id: 'enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0',
|
||||
id: 'fleet-enrollment-api-keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0',
|
||||
refresh: 'true',
|
||||
body: {
|
||||
doc: enrollmentApiKeyDoc,
|
||||
|
|
|
@ -40,18 +40,18 @@ export default function(providerContext: FtrProviderContext) {
|
|||
body: { _source: agentDoc },
|
||||
} = await esClient.get({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
});
|
||||
// @ts-ignore
|
||||
agentDoc.agents.access_api_key_id = accessAPIKeyId;
|
||||
agentDoc.agents.default_api_key_id = outputAPIKeyBody.id;
|
||||
agentDoc.agents.default_api_key = Buffer.from(
|
||||
agentDoc['fleet-agents'].access_api_key_id = accessAPIKeyId;
|
||||
agentDoc['fleet-agents'].default_api_key_id = outputAPIKeyBody.id;
|
||||
agentDoc['fleet-agents'].default_api_key = Buffer.from(
|
||||
`${outputAPIKeyBody.id}:${outputAPIKeyBody.api_key}`
|
||||
).toString('base64');
|
||||
|
||||
await esClient.update({
|
||||
index: '.kibana',
|
||||
id: 'agents:agent1',
|
||||
id: 'fleet-agents:agent1',
|
||||
refresh: 'true',
|
||||
body: {
|
||||
doc: agentDoc,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agents:agent1",
|
||||
"id": "fleet-agents:agent1",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agents",
|
||||
"agents": {
|
||||
"type": "fleet-agents",
|
||||
"fleet-agents": {
|
||||
"access_api_key_id": "api-key-2",
|
||||
"active": true,
|
||||
"shared_id": "agent1_filebeat",
|
||||
|
@ -21,11 +21,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agents:agent2",
|
||||
"id": "fleet-agents:agent2",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agents",
|
||||
"agents": {
|
||||
"type": "fleet-agents",
|
||||
"fleet-agents": {
|
||||
"access_api_key_id": "api-key-2",
|
||||
"active": true,
|
||||
"shared_id": "agent2_filebeat",
|
||||
|
@ -40,11 +40,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agents:agent3",
|
||||
"id": "fleet-agents:agent3",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agents",
|
||||
"agents": {
|
||||
"type": "fleet-agents",
|
||||
"fleet-agents": {
|
||||
"access_api_key_id": "api-key-3",
|
||||
"active": true,
|
||||
"shared_id": "agent3_metricbeat",
|
||||
|
@ -59,11 +59,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agents:agent4",
|
||||
"id": "fleet-agents:agent4",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agents",
|
||||
"agents": {
|
||||
"type": "fleet-agents",
|
||||
"fleet-agents": {
|
||||
"access_api_key_id": "api-key-4",
|
||||
"active": true,
|
||||
"shared_id": "agent4_metricbeat",
|
||||
|
@ -78,17 +78,17 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "enrollment_api_keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0",
|
||||
"id": "fleet-enrollment-api-keys:ed22ca17-e178-4cfe-8b02-54ea29fbd6d0",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"enrollment_api_keys" : {
|
||||
"fleet-enrollment-api-keys" : {
|
||||
"created_at" : "2019-10-10T16:31:12.518Z",
|
||||
"name": "FleetEnrollmentKey:1",
|
||||
"api_key_id" : "key",
|
||||
"config_id" : "policy:1",
|
||||
"active" : true
|
||||
},
|
||||
"type" : "enrollment_api_keys",
|
||||
"type" : "fleet-enrollment-api-keys",
|
||||
"references": []
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "events:event1",
|
||||
"id": "fleet-agent-events:event1",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_events",
|
||||
"agent_events": {
|
||||
"type": "fleet-agent-events",
|
||||
"fleet-agent-events": {
|
||||
"agent_id": "agent1",
|
||||
"type": "STATE",
|
||||
"subtype": "STARTED",
|
||||
|
@ -116,11 +116,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "events:event2",
|
||||
"id": "fleet-agent-events:event2",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_events",
|
||||
"agent_events": {
|
||||
"type": "fleet-agent-events",
|
||||
"fleet-agent-events": {
|
||||
"agent_id": "agent1",
|
||||
"type": "STATE",
|
||||
"subtype": "STOPPED",
|
||||
|
@ -135,11 +135,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agent_actions:37ed51ff-e80f-4f2a-a62d-f4fa975e7d85",
|
||||
"id": "fleet-agent-actions:37ed51ff-e80f-4f2a-a62d-f4fa975e7d85",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_actions",
|
||||
"agent_actions": {
|
||||
"type": "fleet-agent-actions",
|
||||
"fleet-agent-actions": {
|
||||
"agent_id": "agent1",
|
||||
"created_at": "2019-09-04T15:04:07+0000",
|
||||
"type": "RESUME",
|
||||
|
@ -152,11 +152,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agent_actions:b400439c-bbbf-43d5-83cb-cf8b7e32506f",
|
||||
"id": "fleet-agent-actions:b400439c-bbbf-43d5-83cb-cf8b7e32506f",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_actions",
|
||||
"agent_actions": {
|
||||
"type": "fleet-agent-actions",
|
||||
"fleet-agent-actions": {
|
||||
"agent_id": "agent1",
|
||||
"type": "PAUSE",
|
||||
"created_at": "2019-09-04T15:01:07+0000",
|
||||
|
@ -169,11 +169,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agent_actions:48cebde1-c906-4893-b89f-595d943b72a1",
|
||||
"id": "fleet-agent-actions:48cebde1-c906-4893-b89f-595d943b72a1",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_actions",
|
||||
"agent_actions": {
|
||||
"type": "fleet-agent-actions",
|
||||
"fleet-agent-actions": {
|
||||
"agent_id": "agent1",
|
||||
"type": "CONFIG_CHANGE",
|
||||
"created_at": "2020-03-15T03:47:15.129Z",
|
||||
|
@ -186,11 +186,11 @@
|
|||
{
|
||||
"type": "doc",
|
||||
"value": {
|
||||
"id": "agent_actions:48cebde1-c906-4893-b89f-595d943b72a2",
|
||||
"id": "fleet-agent-actions:48cebde1-c906-4893-b89f-595d943b72a2",
|
||||
"index": ".kibana",
|
||||
"source": {
|
||||
"type": "agent_actions",
|
||||
"agent_actions": {
|
||||
"type": "fleet-agent-actions",
|
||||
"fleet-agent-actions": {
|
||||
"agent_id": "agent1",
|
||||
"type": "CONFIG_CHANGE",
|
||||
"created_at": "2020-03-15T03:47:15.129Z",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"dynamic": "strict",
|
||||
"_meta": {
|
||||
"migrationMappingPropertyHashes": {
|
||||
"outputs": "aee9782e0d500b867859650a36280165",
|
||||
"ingest-outputs": "aee9782e0d500b867859650a36280165",
|
||||
"ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9",
|
||||
"visualization": "52d7a13ad68a150c4525b292d23e12cc",
|
||||
"references": "7997cf5a56cc02bdc9c93361bde732b0",
|
||||
|
@ -23,14 +23,14 @@
|
|||
"dashboard": "d00f614b29a80360e1190193fd333bab",
|
||||
"metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd",
|
||||
"siem-detection-engine-rule-actions": "90eee2e4635260f4be0a1da8f5bc0aa0",
|
||||
"agent_events": "3231653fafe4ef3196fe3b32ab774bf2",
|
||||
"fleet-agent-events": "3231653fafe4ef3196fe3b32ab774bf2",
|
||||
"query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9",
|
||||
"file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e",
|
||||
"application_usage_transactional": "965839e75f809fefe04f92dc4d99722a",
|
||||
"action_task_params": "a9d49f184ee89641044be0ca2950fa3a",
|
||||
"apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd",
|
||||
"inventory-view": "9ecce5b58867403613d82fe496470b34",
|
||||
"enrollment_api_keys": "28b91e20b105b6f928e2012600085d8f",
|
||||
"fleet-enrollment-api-keys": "28b91e20b105b6f928e2012600085d8f",
|
||||
"upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6",
|
||||
"cases-comments": "c2061fb929f585df57425102fa928b4b",
|
||||
"canvas-element": "7390014e1091044523666d97247392fc",
|
||||
|
@ -50,20 +50,20 @@
|
|||
"siem-detection-engine-rule-status": "ae783f41c6937db6b7a2ef5c93a9e9b0",
|
||||
"map": "23d7aa4a720d4938ccde3983f87bd58d",
|
||||
"uptime-dynamic-settings": "b6289473c8985c79b6c47eebc19a0ca5",
|
||||
"epm-package": "75d12cd13c867fd713d7dfb27366bc20",
|
||||
"epm-packages": "75d12cd13c867fd713d7dfb27366bc20",
|
||||
"apm-telemetry": "3525d7c22c42bc80f5e6e9cb3f2b26a2",
|
||||
"cases": "08b8b110dbca273d37e8aef131ecab61",
|
||||
"siem-ui-timeline": "ac8020190f5950dd3250b6499144e7fb",
|
||||
"kql-telemetry": "d12a98a6f19a2d273696597547e064ee",
|
||||
"ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3",
|
||||
"url": "c7f66a0df8b1b52f17c28c4adb111105",
|
||||
"agents": "c3eeb7b9d97176f15f6d126370ab23c7",
|
||||
"fleet-agents": "c3eeb7b9d97176f15f6d126370ab23c7",
|
||||
"migrationVersion": "4a1746014a75ade3a714e1db5763276f",
|
||||
"index-pattern": "66eccb05066c5a89924f48a9e9736499",
|
||||
"maps-telemetry": "268da3a48066123fc5baf35abaa55014",
|
||||
"namespace": "2f4316de49999235636386fe51dc06c1",
|
||||
"cases-user-actions": "32277330ec6b721abe3b846cfd939a71",
|
||||
"agent_actions": "ed270b46812f0fa1439366c428a2cf17",
|
||||
"fleet-agent-actions": "ed270b46812f0fa1439366c428a2cf17",
|
||||
"siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29",
|
||||
"timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf",
|
||||
"config": "ae24d22d5986d04124cc6568f771066f",
|
||||
|
@ -107,7 +107,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"agent_actions": {
|
||||
"fleet-agent-actions": {
|
||||
"properties": {
|
||||
"agent_id": {
|
||||
"type": "keyword"
|
||||
|
@ -160,7 +160,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"agent_events": {
|
||||
"fleet-agent-events": {
|
||||
"properties": {
|
||||
"action_id": {
|
||||
"type": "keyword"
|
||||
|
@ -194,7 +194,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"fleet-agents": {
|
||||
"properties": {
|
||||
"access_api_key_id": {
|
||||
"type": "keyword"
|
||||
|
@ -1705,7 +1705,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"enrollment_api_keys": {
|
||||
"fleet-enrollment-api-keys": {
|
||||
"properties": {
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
|
@ -1736,7 +1736,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"epm-package": {
|
||||
"epm-packages": {
|
||||
"properties": {
|
||||
"installed": {
|
||||
"type": "nested",
|
||||
|
@ -2211,7 +2211,7 @@
|
|||
"namespace": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"outputs": {
|
||||
"ingest-outputs": {
|
||||
"properties": {
|
||||
"api_key": {
|
||||
"type": "keyword"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue