Skip to content
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

[7.x] [APM] Fleet: adding support for legacy fields (#110136) #110730

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[APM] Fleet: adding support for legacy fields (#110136)
* supporting legacy fields

* addressing PR comments

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
cauemarcondes and kibanamachine committed Aug 31, 2021
commit 901a253cd056dad047b96ad7c8d15a928d3422cb
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ interface GetApmPackagePolicyDefinitionOptions {
export function getApmPackagePolicyDefinition(
options: GetApmPackagePolicyDefinitionOptions
) {
const { apmServerSchema, cloudPluginSetup } = options;
return {
name: 'Elastic APM',
namespace: 'default',
@@ -27,7 +28,10 @@ export function getApmPackagePolicyDefinition(
type: 'apm',
enabled: true,
streams: [],
vars: getApmPackageInputVars(options),
vars: getApmPackageInputVars({
cloudPluginSetup,
apmServerSchema: preprocessLegacyFields({ apmServerSchema }),
}),
},
],
package: {
@@ -38,6 +42,34 @@ export function getApmPackagePolicyDefinition(
};
}

function preprocessLegacyFields({
apmServerSchema,
}: {
apmServerSchema: Record<string, any>;
}) {
const copyOfApmServerSchema = { ...apmServerSchema };
[
{
key: 'apm-server.auth.anonymous.rate_limit.event_limit',
legacyKey: 'apm-server.rum.event_rate.limit',
},
{
key: 'apm-server.auth.anonymous.rate_limit.ip_limit',
legacyKey: 'apm-server.rum.event_rate.lru_size',
},
{
key: 'apm-server.auth.anonymous.allow_service',
legacyKey: 'apm-server.rum.allow_service_names',
},
].forEach(({ key, legacyKey }) => {
if (!copyOfApmServerSchema[key]) {
copyOfApmServerSchema[key] = copyOfApmServerSchema[legacyKey];
delete copyOfApmServerSchema[legacyKey];
}
});
return copyOfApmServerSchema;
}

function getApmPackageInputVars(options: GetApmPackagePolicyDefinitionOptions) {
const { apmServerSchema } = options;
const apmServerConfigs = Object.entries(
@@ -90,6 +122,18 @@ export const apmConfigMapping: Record<
name: 'rum_allow_headers',
type: 'text',
},
'apm-server.rum.event_rate.limit': {
name: 'rum_event_rate_limit',
type: 'integer',
},
'apm-server.rum.allow_service_names': {
name: 'rum_allow_service_names',
type: 'text',
},
'apm-server.rum.event_rate.lru_size': {
name: 'rum_event_rate_lru_size',
type: 'integer',
},
'apm-server.rum.response_headers': {
name: 'rum_response_headers',
type: 'yaml',