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

[Fleet] Support for APM Agent Central Config with zero configuration #4573

Closed
axw opened this issue Dec 21, 2020 · 7 comments · Fixed by #4670
Closed

[Fleet] Support for APM Agent Central Config with zero configuration #4573

axw opened this issue Dec 21, 2020 · 7 comments · Fixed by #4670

Comments

@axw
Copy link
Member

axw commented Dec 21, 2020

Agent central config depends on APM Server querying Kibana, and having privileges as laid out in https://www.elastic.co/guide/en/apm/server/current/privileges-agent-central-config.html.

When running under Fleet, APM Server will by default not have the necessary privileges to query central config. We will have to either inject secondary credentials for querying Kibana, or somehow extend the privileges of the primary API Key provided by Fleet to APM Server.

Users should not need to care about configuring API Keys for this; they should rather be concerned about enabling or disabling the central config feature, which implicitly updates privileges.

Alternatively: we can reimplement APM Agent Central Config to use Fleet. We would need to:

  • Update the APM app in Kibana to store agent config in (and retrieve from) Fleet policies
    • This config would be pushed down to APM Server, which would store it in memory.
    • Updating APM Agent config must not cause APM Server to restart.
  • Add a means for APM Server to record status for each APM Agent config block (so we can see if the config has been applied)
@simitt
Copy link
Contributor

simitt commented Jan 26, 2021

Created a Kibana issue to track work for this for Fleet elastic/kibana#89311

@axw
Copy link
Member Author

axw commented Feb 15, 2021

Reopening and changing the description so we don't lose sight of enabling this feature without manually injecting API Keys.

@axw axw reopened this Feb 15, 2021
@axw axw changed the title [Fleet] Support for APM Agent Central Config [Fleet] Support for APM Agent Central Config with zero configuration Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config with zero configuration [Fleet] Support for APM Agent Central Config Feb 15, 2021
@zube zube bot added [zube]: Inbox and removed [zube]: Done labels Feb 15, 2021
@zube zube bot closed this as completed Feb 15, 2021
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config [Fleet] Support for APM Agent Central Config with zero configuration Feb 15, 2021
@zube zube bot reopened this Feb 15, 2021
@zube zube bot added [zube]: Inbox and removed [zube]: Done labels Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config with zero configuration [Fleet] Support for APM Agent Central Config Feb 15, 2021
@zube zube bot closed this as completed Feb 15, 2021
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config [Fleet] Support for APM Agent Central Config with zero configuration Feb 15, 2021
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config [Fleet] Support for APM Agent Central Config with zero configuration Feb 15, 2021
@zube zube bot reopened this Feb 15, 2021
@zube zube bot added [zube]: Inbox and removed [zube]: Done labels Feb 15, 2021
@zube zube bot changed the title [Fleet] Support for APM Agent Central Config with zero configuration [Fleet] Support for APM Agent Central Config Feb 15, 2021
@zube zube bot closed this as completed Feb 15, 2021
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Feb 15, 2021
@axw axw reopened this Feb 15, 2021
@axw axw changed the title [Fleet] Support for APM Agent Central Config [Fleet] Support for APM Agent Central Config with zero configuration Feb 16, 2021
@axw axw added this to the 7.13 milestone Feb 16, 2021
@axw
Copy link
Member Author

axw commented Feb 24, 2021

We will have to either inject secondary credentials for querying Kibana, or somehow extend the privileges of the primary API Key provided by Fleet to APM Server.

Fleet provides extension points for the package policy create and update APIs.

Information courtesy of Paul Tavares:

API hooks available for Package policies (aka: integration policies): one for Create and another for Update. To use them, a dependency must be set on your kibana Plugin to Fleet, which will then expose FleetStartContract during the start phase of the plugin's lifecycle. This interface includes a method named registerExternalCallback() which allows you to register a callback function for the following:

fleetStart.registerExternalCallback('packagePolicyCraete', async () => {});
and 
fleetStart.registerExternalCallback('packagePolicyUpdate', async () => {});
The Types for the callbacks supported are defined here: https://github.com/elastic/kibana/blob/a99ccc27d7a9d2ad7be162c21f545e8eebf59c69/x-pack/plugins/fleet/server/plugin.ts#L132-L148 

So what we should be able to do is have the APM app hook into these API calls, and inject one or more additional API Keys. This could be done without elastic/kibana#89311.

Alternatively/additionally we could use the same mechanism to inject APM agent config into APM package policies. When a package policy is created or updated we would inject the APM agent config through the hook, and in subsequent changes to APM agent config we would update the package policy to keep them in sync. With this kind of approach we would need an alternative means of marking agent config as "applied".

I think the latter approach is probably what we should aim for, but in the near term we should keep the number of changes down and inject additional privileges. This will be necessary anyway for tail-based sampling.

@simitt
Copy link
Contributor

simitt commented Mar 2, 2021

So what we should be able to do is have the APM app hook into these API calls, and inject one or more additional API Keys. This could be done without elastic/kibana#89311.

In scenarios where the Kibana API Key needs to be revoked, I believe it is fair to let the users revoke it manually. But we would need a way to convince the hook to actually create a new one.

@simitt
Copy link
Contributor

simitt commented Mar 3, 2021

No direct work on the APM Server side, created elastic/kibana#93420 for the suggested solution.

@axw
Copy link
Member Author

axw commented Mar 26, 2021

We have elastic/kibana#93420 for the interim solution, and I've just opened #5018 and elastic/kibana#95501 for the final solution. Closing this one, let's iterate on those issues as needed.

@axw axw closed this as completed Mar 26, 2021
@axw
Copy link
Member Author

axw commented Mar 30, 2021

See elastic/kibana#93420 (comment) for proof of concepts

@axw axw removed the [zube]: Done label Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants