-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Syncs agent config settings to APM Fleet policies #100744
[APM] Syncs agent config settings to APM Fleet policies #100744
Conversation
Pinging @elastic/apm-ui (Team:apm) |
const configurations = await listConfigurations({ setup }); | ||
const agentConfigValue = configurations.map((configuration) => ({ | ||
service: configuration.service, | ||
settings: configuration.settings, |
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.
settings: configuration.settings, | |
config: configuration.settings, |
Here's how things look in apm-server currentlly: https://github.com/elastic/apm-server/blob/91645bde2d96a79b943c90253d62da3861ab2997/apm-server.yml#L275-L297
#---------------------------- APM Server - Agent Configuration ----------------------------
# Directly specify agent configuration. If `agent_config` is set, agent
# configuration under `kibana` will be ignored.
# An agent's incoming configuration request will be matched to an
# agent_config with the following precedence:
# - service.name and service.environment match an agent_config
# - service.name matches an agent_config, service.environment == ""
# - service.environment matches an agent_config, service.name == ""
# - an agent_config without a name or environment set
# An empty result is is returned if no matching result is found.
# agent_config:
# - service.name: ten_percent
# service.environment: production
# config:
# capture_body: off
# capture_body: true
# log_level: info
# recording: true
# transaction_sample_rate: 0.1
# - service.name: frontend
# agent.name: rum-js
# config:
# transaction_sample_rate: 0.1
We could alternatively change the apm-server implementation if you/anyone feels strongly about calling this "settings".
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.
I'm ok changing it to conform with apm-server's implementation. thanks!
const agentConfigValue = configurations.map((configuration) => ({ | ||
service: configuration.service, | ||
settings: configuration.settings, | ||
})); |
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.
})); | |
etag: configuration.etag, | |
'agent.name': configuration.agent_name, | |
})); |
By passing the etag
value down, apm-server will (later) be able to use it when recording which config has been applied by agents. The UI can then match this up to the config blocks it knows about.
We also need agent.name
for restricting config for untrusted agents (RUM and Jaeger)
…icy objects - update package policy agent_configs to include etag, agent.name, and change settings -> config
@ogupte could you give some instructions about how to test it, please? |
setup, | ||
}); | ||
logger.info( | ||
`Saved latest agent settings to Fleet integration policy for APM.` |
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.
Since you're logging something, maybe would be good to have a specific message when it is deleting?
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.
LGTM - Nice work @ogupte
@stuartnelson3, thanks for checking this out and testing it.
|
👍 sorry @stuartnelson3, I missed that we had numbers in our config in the
I would prefer that everything specific to APM is nested under the |
this ended up being correctly sent to diff --git a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts
index bfc9d360..8ff34d96 100644
--- a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts
+++ b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts
@@ -106,7 +106,7 @@ export function getPackagePolicyWithAgentConfigurations(
{
...firstInput,
config: {
- agent_config: {
+ 'apm-server.agent_config': {
value: agentConfigurations.map((configuration) => ({
service: configuration.service,
config: configuration.settings, EDIT: I'm not sure what's going on with the rendering of |
@elasticmachine merge upstream |
@stuartnelson3 can you confirm that this works: https://github.com/elastic/kibana/pull/100744/files#diff-ab7e62a4c711e2133e13004dec4ecfedd8bb1bf46da87eed88f61bd743b2ffd4R118-R128 |
@elasticmachine merge upstream |
…-server'] in order to pass validation checks
@stuartnelson3 in order to fix the validation error I had to define a property |
- parallelizes operations for improved performance
@stuartnelson3 It looks like the fleet kibana code which generates that yaml spreads in the contents of is apm-server consuming these agent configs with the raw policy object, or only through this output yaml? |
config: { | ||
[APM_SERVER]: { |
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.
@ogupte Don't you need to add the others config
here to avoid overwriting the entire config object?
config: { | |
[APM_SERVER]: { | |
config: { | |
...firstInput.config, | |
[APM_SERVER]: { |
@ogupte apm-server will receive the combined output yaml. Maybe flatten the config string, so it's added like |
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
* [APM] Syncs agent config settings to APM Fleet policies (elastic#95501) * fixes eslint issues * fixes malformed line comment * - consolidated logic that applies agent configurations to package policy objects - update package policy agent_configs to include etag, agent.name, and change settings -> config * Synchronizes agent configs whenever configuration is deleted. * PR feedback * nest agent_config within `apm-server` in the package policy input * nests agent_config under the requried 'value' property of config['apm-server'] in order to pass validation checks * - externalizes getApmPackagePolicies for reusability - parallelizes operations for improved performance Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…01685) * [APM] Syncs agent config settings to APM Fleet policies (#95501) * fixes eslint issues * fixes malformed line comment * - consolidated logic that applies agent configurations to package policy objects - update package policy agent_configs to include etag, agent.name, and change settings -> config * Synchronizes agent configs whenever configuration is deleted. * PR feedback * nest agent_config within `apm-server` in the package policy input * nests agent_config under the requried 'value' property of config['apm-server'] in order to pass validation checks * - externalizes getApmPackagePolicies for reusability - parallelizes operations for improved performance Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* master: (54 commits) Implement "select all" rules feature (elastic#100554) [ML] Remove script fields from the Anomaly detection alerting rule executor (elastic#101607) [Security solutions][Endpoint] Update event filtering texts (elastic#101563) [Enterprise Search] Mocks/tests tech debt - avoid hungry mocking (elastic#101107) [FTR] Updates esArchive paths [FTR] Updates esArchive paths [Security Solution][Detection Engine] Adds runtime field tests (elastic#101664) Added APM PHP agent to the list of agent names (elastic#101062) [CI] Restore old version_info behavior when .git directory is present (elastic#101642) [Fleet] Add fleet server telemetry (elastic#101400) [APM] Syncs agent config settings to APM Fleet policies (elastic#100744) [esArchiver] drop support for --dir, use repo-relative paths instead (elastic#101345) Revert "[xpack/test] restore incremental: false in ts project" [Security Solution] Remove Host Isolation feature flag (elastic#101655) [xpack/test] restore incremental: false in ts project [DOCS] Adds link to video landing page (elastic#101413) [ML] Move Index Data Visualizer into separate plugin (Part 1) (elastic#100922) Improve security plugin return types (elastic#101492) [ts] migrate `x-pack/test` to composite ts project (elastic#101441) [App Search] Updated Search UI to new URL (elastic#101320) ...
Closes #95501.
Synchronizes all agent configuration settings with existing APM fleet policies whenever any user creates/updates any agent configuration via API endpoint
PUT /api/apm/settings/agent-configuration
.Can be tested with apm-integration-testing
python3 ./scripts/compose.py start master --with-elastic-agent --apm-server-managed --all
. Update an agent confuration in APM UI, then inspect the response fromhttp://localhost:5601/api/fleet/package_policies
to verify that the agent configs are updated in the apm package policy object.