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

[APM] Fleet: Inject Kibana URL + API Key into APM integration policy #93420

Closed
simitt opened this issue Mar 3, 2021 · 6 comments
Closed

[APM] Fleet: Inject Kibana URL + API Key into APM integration policy #93420

simitt opened this issue Mar 3, 2021 · 6 comments
Labels
apm:fleet Team:APM All issues that need APM UI Team support v7.13.0

Comments

@simitt
Copy link
Contributor

simitt commented Mar 3, 2021

This is an interim solution. The permanent solution is #95501


image

Hook into Fleet extension points to create and inject a Kibana API Key and the Kibana URL to the APM integration policy. The API Key need to be checked on every packagePolicyUpdate as the key might be invalidated by users, in which case a new key needs to be created.
Permissions for key creation should not be an issue, as Fleet requires superuser privileges.


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('packagePolicyCreate', async () => {});
fleetStart.registerExternalCallback('packagePolicyUpdate', async () => {});

The Types for the callbacks supported are defined here:

export type ExternalCallback =
| [
'packagePolicyCreate',
(
newPackagePolicy: NewPackagePolicy,
context: RequestHandlerContext,
request: KibanaRequest
) => Promise<NewPackagePolicy>
]
| [
'packagePolicyUpdate',
(
newPackagePolicy: UpdatePackagePolicy,
context: RequestHandlerContext,
request: KibanaRequest
) => Promise<UpdatePackagePolicy>
];

The APM app should hook into these API calls, and inject one or more additional API Keys. This could be done without #89311.


This issue supersedes #89311
Related discussion: elastic/apm-server#4573 (comment)

@simitt simitt added Team:APM All issues that need APM UI Team support v7.13.0 apm:fleet labels Mar 3, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@felixbarny
Copy link
Member

Alex already created an issue for that: #88822

@sorenlouv sorenlouv changed the title Inject Kibana URL + API Key into APM integration policy in Fleet [APM] Inject Kibana URL + API Key into APM integration policy in Fleet Mar 5, 2021
@sorenlouv sorenlouv changed the title [APM] Inject Kibana URL + API Key into APM integration policy in Fleet [APM] Fleet: Inject Kibana URL + API Key into APM integration policy Mar 5, 2021
@axw
Copy link
Member

axw commented Mar 6, 2021

To try and help get things started, I've prototyped a couple of things:

It's all hacks, just use it for inspiration if anything.

The approach of injecting config is probably what we should eventually take. Since with that approach APM Server wouldn't be connecting to Kibana at all, we would need to come up with a new way of indicating that agent config has been applied. I'm also not sure if this will work with our security model.

@sorenlouv
Copy link
Member

Thanks @axw, much appreciated! This provides some great pointers for what to do next

@elastic elastic deleted a comment from felixbarny Mar 8, 2021
@simitt
Copy link
Contributor Author

simitt commented Mar 8, 2021

update: I deleted a bunch of comments on this issue and moved them over to #89989 (comment). Apologies for this mess!

@elastic elastic deleted a comment from felixbarny Mar 8, 2021
@simitt
Copy link
Contributor Author

simitt commented Apr 6, 2021

Since we decided to not work on an iterims solution for 7.13, closing this issue in favor of #95501.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:fleet Team:APM All issues that need APM UI Team support v7.13.0
Projects
None yet
Development

No branches or pull requests

6 participants