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] Improve public API for Agent Policy, Package Policy #113750

Closed
Tracked by #123150
nchaulet opened this issue Oct 4, 2021 · 9 comments · Fixed by #119739
Closed
Tracked by #123150

[Fleet] Improve public API for Agent Policy, Package Policy #113750

nchaulet opened this issue Oct 4, 2021 · 9 comments · Fixed by #119739
Assignees
Labels
enhancement New value added to drive a business result Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@nchaulet
Copy link
Member

nchaulet commented Oct 4, 2021

Description

While working on proof of concept of a terraform provider for Fleet I had to work with the Fleet APIs outside of Kibana. I found these APIs really hard to consume as you need to provide to much information and have a lot of knowledge on how packages are structured.

To add a package you need to provide things that I think are not necessary like the package title, all the information on the variables (we can compute that)

Potential solutions

I think we can a new API that allow to return easily the inputs,streams, and variables for a package (eventually we can use that to display how to programatically configure an integration in the UI)

We could create a new version of the package policy API that accept something more similar to the preconfigure API and we can compute a lot more things based on the package server side (it will be less error prone too)

Something like this

{
  "package": {
    "name": "fleet_server",
    "version": "0.0.1"
  },
  "name": "Fleet Server",
  "inputs": [
    {
      "type": "fleet-server",
      "keep_enabled": true
    }
  ]
}
@nchaulet nchaulet added enhancement New value added to drive a business result Team:Fleet Team label for Observability Data Collection Fleet team labels Oct 4, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@mostlyjason
Copy link
Contributor

@nchaulet would this require a breaking change to switch to this improved format that we should aim for 8.0 or can we add it as an enhancement later?

@nchaulet
Copy link
Member Author

nchaulet commented Oct 4, 2021

@nchaulet would this require a breaking change to switch to this improved format that we should aim for 8.0 or can we add it as an enhancement later?

I think making this a breaking change is probably a better option so we will not have to maintains the old API for the whole 8.x cycle. Also in my opinion providing a good API here is a huge enhancement for users that can open the door to more IAC tooling.

@juliaElastic
Copy link
Contributor

@nchaulet I had a look at this, and I think we can't remove as many properties from the package_policies API, there are a lot of options that can be customised from UI, so those cannot be removed, e.g. inputs.streams or inputs.vars.

Wouldn't it be better to create a parallel create API that would take the minimal information and enrich the rest from server side?

Also, is this a priority issue? Since it is not there in current Iteration.

@kpollich
Copy link
Member

@nchaulet I had a look at this, and I think we can't remove as many properties from the package_policies API, there are a lot of options that can be customised from UI, so those cannot be removed, e.g. inputs.streams or inputs.vars.

Wouldn't it be better to create a parallel create API that would take the minimal information and enrich the rest from server side?

Also, is this a priority issue? Since it is not there in current Iteration.

I think the idea here would be to make those fields optional rather than required, so we can support a more minimal payload when users aren't submitting data via the policy editor. The logic here should be "anything that can be computed server-side from the package info is optional" - if that makes sense.

I am not in favor of a simplified special case endpoint that accepts this minimal payload, as that seems like introducing multiple sources of truth.

@juliaElastic
Copy link
Contributor

@kpollich I see your point, so it sounds like this won't be a breaking change?
I would rather not introduce breaking change in 8.0 at this point, see this discussion: elastic/elastic-agent#111

The only tricky part might be to merge together properties overwritten from UI and default values.

@juliaElastic
Copy link
Contributor

Regarding the update API, shouldn't we use HTTP PATCH instead of making fields optional in PUT? Though it would mean to have 2 APIs for update.

@juliaElastic
Copy link
Contributor

@nchaulet did you mean to change anything in Agent Policy API too? I had a check and only name and namespace is required when creating or updating an agent policy, see NewAgentPolicy
That should be sufficient, do you agree?

@criamico
Copy link
Contributor

criamico commented Dec 9, 2021

Adding here the PR as it was not linked: #119739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants