Skip to content

Commit

Permalink
[Ingest Manager] Move config from xpack.ingestManager to xpack.fleet (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Oct 6, 2020
1 parent 24e4536 commit c355dfe
Show file tree
Hide file tree
Showing 32 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ the infrastructure monitoring use-case within Kibana.
|{kib-repo}blob/{branch}/x-pack/plugins/ingest_manager/README.md[ingestManager]
|Fleet needs to have Elasticsearch API keys enabled, and also to have TLS enabled on kibana, (if you want to run Kibana without TLS you can provide the following config flag --xpack.ingestManager.fleet.tlsCheckDisabled=false)
|Fleet needs to have Elasticsearch API keys enabled, and also to have TLS enabled on kibana, (if you want to run Kibana without TLS you can provide the following config flag --xpack.fleet.agents.tlsCheckDisabled=false)
|{kib-repo}blob/{branch}/x-pack/plugins/ingest_pipelines/README.md[ingestPipelines]
Expand Down
14 changes: 7 additions & 7 deletions docs/settings/ingest-manager-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

experimental[]

You can configure `xpack.ingestManager` settings in your `kibana.yml`.
You can configure `xpack.fleet` settings in your `kibana.yml`.
By default, {ingest-manager} is enabled. To use {fleet}, you also need to configure {kib} and {es} hosts.

See the {ingest-guide}/index.html[Ingest Management] docs for more information.
Expand All @@ -17,9 +17,9 @@ See the {ingest-guide}/index.html[Ingest Management] docs for more information.

[cols="2*<"]
|===
| `xpack.ingestManager.enabled` {ess-icon}
| `xpack.fleet.enabled` {ess-icon}
| Set to `true` (default) to enable {ingest-manager}.
| `xpack.ingestManager.fleet.enabled` {ess-icon}
| `xpack.fleet.agents.enabled` {ess-icon}
| Set to `true` (default) to enable {fleet}.
|===

Expand All @@ -29,19 +29,19 @@ See the {ingest-guide}/index.html[Ingest Management] docs for more information.

[cols="2*<"]
|===
| `xpack.ingestManager.registryUrl`
| `xpack.fleet.registryUrl`
| The address to use to reach {package-manager} registry.
|===

==== {fleet} settings

[cols="2*<"]
|===
| `xpack.ingestManager.fleet.kibana.host`
| `xpack.fleet.agents.kibana.host`
| The hostname used by {agent} for accessing {kib}.
| `xpack.ingestManager.fleet.elasticsearch.host`
| `xpack.fleet.agents.elasticsearch.host`
| The hostname used by {agent} for accessing {es}.
| `xpack.ingestManager.fleet.tlsCheckDisabled`
| `xpack.fleet.agents.tlsCheckDisabled`
| Set to `true` to allow {fleet} to run on a {kib} instance without TLS enabled.
|===

Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/ingest_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
## Plugin

- The plugin is enabled 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)
- Adding `xpack.ingestManager.enabled=false` will disable the plugin including the EPM and Fleet features. It will also remove the `PACKAGE_POLICY_API_ROUTES` and `AGENT_POLICY_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts)
- Adding `--xpack.ingestManager.fleet.enabled=false` will disable the Fleet API & UI
- Adding `xpack.fleet.enabled=false` will disable the plugin including the EPM and Fleet features. It will also remove the `PACKAGE_POLICY_API_ROUTES` and `AGENT_POLICY_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts)
- Adding `--xpack.fleet.agents.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.
- For Enterprise license, a custom package registry URL can be used by setting `xpack.ingestManager.registryUrl=http://localhost:8080`
- For Enterprise license, a custom package registry URL can be used by setting `xpack.fleet.registryUrl=http://localhost:8080`
- This property is currently only for internal Elastic development and is unsupported

## Fleet Requirements

Fleet needs to have Elasticsearch API keys enabled, and also to have TLS enabled on kibana, (if you want to run Kibana without TLS you can provide the following config flag `--xpack.ingestManager.fleet.tlsCheckDisabled=false`)
Fleet needs to have Elasticsearch API keys enabled, and also to have TLS enabled on kibana, (if you want to run Kibana without TLS you can provide the following config flag `--xpack.fleet.agents.tlsCheckDisabled=false`)

Also you need to configure the hosts your agent is going to use to comunication with Elasticsearch and Kibana (Not needed if you use Elastic cloud). You can use the following flags:

```
--xpack.ingestManager.fleet.elasticsearch.host=http://localhost:9200
--xpack.ingestManager.fleet.kibana.host=http://localhost:5601
--xpack.fleet.agents.elasticsearch.host=http://localhost:9200
--xpack.fleet.agents.kibana.host=http://localhost:5601
```

## Development
Expand All @@ -40,7 +40,7 @@ One common development workflow is:
```
- Start Kibana in another shell
```
yarn start --xpack.ingestManager.enabled=true --no-base-path
yarn start --xpack.fleet.enabled=true --no-base-path
```

This plugin follows the `common`, `server`, `public` structure from the [Architecture Style Guide
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from './rest_spec';
export interface IngestManagerConfigType {
enabled: boolean;
registryUrl?: string;
fleet: {
agents: {
enabled: boolean;
tlsCheckDisabled: boolean;
pollingRequestTimeout: number;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "kibana",
"server": true,
"ui": true,
"configPath": ["xpack", "ingestManager"],
"configPath": ["xpack", "fleet"],
"requiredPlugins": ["licensing", "data", "encryptedSavedObjects"],
"optionalPlugins": ["security", "features", "cloud", "usageCollection", "home"],
"extraPublicDirs": ["common"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const FleetStatusContext = React.createContext<FleetStatus | undefined>(undefine
export const FleetStatusProvider: React.FC = ({ children }) => {
const config = useConfig();
const [state, setState] = useState<FleetStatusState>({
enabled: config.fleet.enabled,
enabled: config.agents.enabled,
isLoading: false,
isReady: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const ErrorLayout = ({ children }: { children: JSX.Element }) => (
const IngestManagerRoutes = memo<{ history: AppMountParameters['history']; basepath: string }>(
({ history, ...rest }) => {
useBreadcrumbs('base');
const { fleet } = useConfig();
const { agents } = useConfig();

const { notifications } = useCore();

const [isPermissionsLoading, setIsPermissionsLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -209,7 +210,7 @@ const IngestManagerRoutes = memo<{ history: AppMountParameters['history']; basep
<DataStreamApp />
</DefaultLayout>
</Route>
<ProtectedRoute path={PAGE_ROUTING_PATHS.fleet} isAllowed={fleet.enabled}>
<ProtectedRoute path={PAGE_ROUTING_PATHS.fleet} isAllowed={agents.enabled}>
<DefaultLayout section="fleet">
<FleetApp />
</DefaultLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DefaultLayout: React.FunctionComponent<Props> = ({
children,
}) => {
const { getHref } = useLink();
const { fleet } = useConfig();
const { agents } = useConfig();
const [isSettingsFlyoutOpen, setIsSettingsFlyoutOpen] = React.useState(false);

return (
Expand Down Expand Up @@ -80,7 +80,7 @@ export const DefaultLayout: React.FunctionComponent<Props> = ({
<EuiTab
isSelected={section === 'fleet'}
href={getHref('fleet')}
disabled={!fleet?.enabled}
disabled={!agents?.enabled}
>
<FormattedMessage
id="xpack.ingestManager.appNavigation.agentsLinkText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type OnSuccessCallback = (agentPolicyDeleted: string) => void;
export const AgentPolicyDeleteProvider: React.FunctionComponent<Props> = ({ children }) => {
const { notifications } = useCore();
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();
const [agentPolicy, setAgentPolicy] = useState<string>();
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const PackagePolicyDeleteProvider: React.FunctionComponent<Props> = ({
}) => {
const { notifications } = useCore();
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();
const [packagePolicies, setPackagePolicies] = useState<string[]>([]);
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => {
application: { navigateToApp },
} = useCore();
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();
const {
params: { policyId, pkgkey },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SettingsView = memo<{ agentPolicy: AgentPolicy }>(
({ agentPolicy: originalAgentPolicy }) => {
const { notifications } = useCore();
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();
const history = useHistory();
const { getPath } = useLink();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { StepDefinePackagePolicy } from '../create_package_policy_page/step_defi
export const EditPackagePolicyPage: React.FunctionComponent = () => {
const { notifications } = useCore();
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();
const {
params: { policyId, packagePolicyId },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const AgentPolicyListPage: React.FunctionComponent<{}> = () => {
const { getHref, getPath } = useLink();
const hasWriteCapabilites = useCapabilities().write;
const {
fleet: { enabled: isFleetEnabled },
agents: { enabled: isFleetEnabled },
} = useConfig();

// Table and search states
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { ListLayout } from './components/list_layout';
export const FleetApp: React.FunctionComponent = () => {
useBreadcrumbs('fleet');
const core = useCore();
const { fleet } = useConfig();
const { agents } = useConfig();

const fleetStatus = useFleetStatus();

if (!fleet.enabled) return null;
if (!agents.enabled) return null;
if (fleetStatus.isLoading) {
return <Loading />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ xpack.security.authc.api_key.enabled: true`}
/>
</EuiLink>
),
tlsFlag: <EuiCode>xpack.ingestManager.fleet.tlsCheckDisabled</EuiCode>,
tlsFlag: <EuiCode>xpack.fleet.agents.tlsCheckDisabled</EuiCode>,
true: <EuiCode>true</EuiCode>,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
import { IngestManagerConfigType } from '..';

export const getIsFleetEnabled = (config: IngestManagerConfigType) => {
return config.fleet.enabled;
return config.agents.enabled;
};
12 changes: 8 additions & 4 deletions x-pack/plugins/ingest_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginInitializerContext } from 'src/core/server';
import { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';
import { IngestManagerPlugin } from './plugin';
import {
AGENT_POLICY_ROLLOUT_RATE_LIMIT_INTERVAL_MS,
Expand All @@ -19,15 +19,19 @@ export {
ExternalCallback,
} from './plugin';

export const config = {
export const config: PluginConfigDescriptor = {
exposeToBrowser: {
epm: true,
fleet: true,
agents: true,
},
deprecations: ({ renameFromRoot }) => [
renameFromRoot('xpack.ingestManager.fleet', 'xpack.fleet.agents'),
renameFromRoot('xpack.ingestManager', 'xpack.fleet'),
],
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
registryUrl: schema.maybe(schema.uri()),
fleet: schema.object({
agents: schema.object({
enabled: schema.boolean({ defaultValue: true }),
tlsCheckDisabled: schema.boolean({ defaultValue: false }),
pollingRequestTimeout: schema.number({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class IngestManagerPlugin
registerEPMRoutes(router);

// Conditional config routes
if (config.fleet.enabled) {
if (config.agents.enabled) {
const isESOUsingEphemeralEncryptionKey =
deps.encryptedSavedObjects.usingEphemeralEncryptionKey;
if (isESOUsingEphemeralEncryptionKey) {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/routes/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType)
getAgentsHandler
);

const pollingRequestTimeout = config.fleet.pollingRequestTimeout;
const pollingRequestTimeout = config.agents.pollingRequestTimeout;
// Agent checkin
router.post(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ import { IngestManagerConfigType } from '../index';
describe('registerLimitedConcurrencyRoutes', () => {
test(`doesn't call registerOnPreAuth if maxConcurrentConnections is 0`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 0 } } as IngestManagerConfigType;
const mockConfig = { agents: { maxConcurrentConnections: 0 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).not.toHaveBeenCalled();
});

test(`calls registerOnPreAuth once if maxConcurrentConnections is 1`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 1 } } as IngestManagerConfigType;
const mockConfig = { agents: { maxConcurrentConnections: 1 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
});

test(`calls registerOnPreAuth once if maxConcurrentConnections is 1000`, async () => {
const mockSetup = coreMock.createSetup();
const mockConfig = { fleet: { maxConcurrentConnections: 1000 } } as IngestManagerConfigType;
const mockConfig = { agents: { maxConcurrentConnections: 1000 } } as IngestManagerConfigType;
registerLimitedConcurrencyRoutes(mockSetup, mockConfig);

expect(mockSetup.http.registerOnPreAuth).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function createLimitedPreAuthHandler({
}

export function registerLimitedConcurrencyRoutes(core: CoreSetup, config: IngestManagerConfigType) {
const max = config.fleet.maxConcurrentConnections;
const max = config.agents.maxConcurrentConnections;
if (!max) return;

core.http.registerOnPreAuth(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getFleetStatusHandler: RequestHandler = async (context, request, re
const isTLSEnabled = appContextService.getHttpSetup().getServerInfo().protocol === 'https';
const isProductionMode = appContextService.getIsProductionMode();
const isCloud = appContextService.getCloud()?.isCloudEnabled ?? false;
const isTLSCheckDisabled = appContextService.getConfig()?.fleet?.tlsCheckDisabled ?? false;
const isTLSCheckDisabled = appContextService.getConfig()?.agents?.tlsCheckDisabled ?? false;
const isUsingEphemeralEncryptionKey = appContextService.getEncryptedSavedObjectsSetup()
.usingEphemeralEncryptionKey;

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/routes/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const registerRoutes = (router: IRouter, config: IngestManagerConfigType)
// Ingest manager setup
registerIngestManagerSetupRoute(router);

if (!config.fleet.enabled) {
if (!config.agents.enabled) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,12 @@ export async function createAgentActionFromPolicyAction(
}

function getPollingTimeoutMs() {
const pollingTimeoutMs = appContextService.getConfig()?.fleet.pollingRequestTimeout ?? 0;
const pollingTimeoutMs = appContextService.getConfig()?.agents.pollingRequestTimeout ?? 0;

// If polling timeout is too short do not use margin
if (pollingTimeoutMs <= AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS) {
return pollingTimeoutMs;
}

// Set a timeout 20s before the real timeout to have a chance to respond an empty response before socket timeout
return Math.max(
pollingTimeoutMs - AGENT_POLLING_REQUEST_TIMEOUT_MARGIN_MS,
Expand All @@ -193,10 +192,10 @@ export function agentCheckinStateNewActionsFactory() {
const pollingTimeoutMs = getPollingTimeoutMs();

const rateLimiterIntervalMs =
appContextService.getConfig()?.fleet.agentPolicyRolloutRateLimitIntervalMs ??
appContextService.getConfig()?.agents.agentPolicyRolloutRateLimitIntervalMs ??
AGENT_POLICY_ROLLOUT_RATE_LIMIT_INTERVAL_MS;
const rateLimiterRequestPerInterval =
appContextService.getConfig()?.fleet.agentPolicyRolloutRateLimitRequestPerInterval ??
appContextService.getConfig()?.agents.agentPolicyRolloutRateLimitRequestPerInterval ??
AGENT_POLICY_ROLLOUT_RATE_LIMIT_REQUEST_PER_INTERVAL;
const rateLimiterMaxDelay = pollingTimeoutMs;

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ingest_manager/server/services/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class OutputService {
const cloud = appContextService.getCloud();
const cloudId = cloud?.isCloudEnabled && cloud.cloudId;
const cloudUrl = cloudId && decodeCloudId(cloudId)?.elasticsearchUrl;
const flagsUrl = appContextService.getConfig()!.fleet.elasticsearch.host;
const flagsUrl = appContextService.getConfig()!.agents.elasticsearch.host;
const defaultUrl = 'http://localhost:9200';
const defaultOutputUrl = cloudUrl || flagsUrl || defaultUrl;

if (!outputs.saved_objects.length) {
const newDefaultOutput = {
...DEFAULT_OUTPUT,
hosts: [defaultOutputUrl],
ca_sha256: appContextService.getConfig()!.fleet.elasticsearch.ca_sha256,
ca_sha256: appContextService.getConfig()!.agents.elasticsearch.ca_sha256,
} as NewOutput;

return await this.create(soClient, newDefaultOutput);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function createDefaultSettings(): BaseSettings {
const cloud = appContextService.getCloud();
const cloudId = cloud?.isCloudEnabled && cloud.cloudId;
const cloudUrl = cloudId && decodeCloudId(cloudId)?.kibanaUrl;
const flagsUrl = appContextService.getConfig()?.fleet?.kibana?.host;
const flagsUrl = appContextService.getConfig()?.agents?.kibana?.host;
const defaultUrl = url.format({
protocol: serverInfo.protocol,
hostname: serverInfo.hostname,
Expand Down
Loading

0 comments on commit c355dfe

Please sign in to comment.