-
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
[Fleet] Add a human-readable API and documentation for configuring package policies #132263
Comments
Pinging @elastic/fleet (Team:Fleet) |
Adding another concrete example that I believe would be worth changing before making the API GA:
IMO it should be changed to
|
Is there any guidance on doing this day, or is it recommended to use the UI for now until further changes are made? For context, we're trying to automate applying similar-but-different package policies across multiple agents in multiple environments, and having to manually provision them today is a lot. (Ideally we eventually get elastic/terraform-provider-elasticstack#89, but even a half step would be great) |
@joshdover |
@juliaElastic Yes, we should open a package-spec discussion about this. I think this will be important for the long-term. Otherwise, it's very easy for a package author to introduce a breaking change in their package, simply by re-ordering their inputs. |
Trying to summarize the different level we will have to document for an integration you could have
|
In terms of introducing a simplified form of the package policy API, it seems like there is quite a bit of room to simplify the existing API without adding input IDs with an eye towards what that could look like too: Existing API call{
"name": "system-5",
"package": {
"name": "system",
"version": "1.19.1"
},
"inputs": [
{
"policy_template": "system",
"type": "logfile",
"enabled": true,
"streams": [
{
"enabled": true,
"data_stream": {
"type": "logs",
"dataset": "system.auth"
},
"vars": {
"preserve_original_event": {
"value": true
},
"paths": {
"value": ["/var/log/auth.log*"]
},
"tags": {
"value": ["test"]
}
}
}
]
},
]
} Simplified streams sectionThere are some improvements we could make the
{
"name": "system-5",
"package": {
"name": "system",
"version": "1.19.1"
},
"inputs": [
{
"policy_template": "system",
"type": "logfile",
"enabled": true,
"streams": {
"system.auth": { // `data_stream.dataset` is used for the key
// `data_stream.type` looked up from package
// `enabled: true` is assumed
// keys are vars, values are values (no nested `values` key necessary)
"preserve_original_event": true,
"paths": ["/var/log/auth.log*"],
"tags": ["test"]
}
}
}
]
} Simplified inputs section (requires packages to add input IDs elastic/package-spec#385)If we supported a human readable ID for each input, we'd be able to make further assumptions to simplify the inputs part of the API:
{
"name": "system-5",
"package": "system",
"inputs": {
"system_auth": { // input id is used as key (NEW: this doesn't exist yet in packages)
// `enabled: true` is assumed
// `policy_template` is not required if there is only 1 template
"streams": {
"system.auth": { // `data_stream.dataset` is used for the key
// `data_stream.type` looked up from package
// `enabled: true` is assumed
// keys are vars, values are values
"preserve_original_event": true,
"paths": ["/var/log/auth.log*"],
"tags": ["test"]
}
}
}
}
} @nchaulet curious if there's any complexity I'm missing here (I'm sure there is) |
@joshdover I like the idea of using object here instead of array make things a lot more readable, we may have some additional key at the same level as Alsofor the input id I am wondering if we can generate it on Fleet size if it's not present in the package I am going to dig a little more into that and see if there is some limitations here, and how we can bring that change. |
One downside to this is that packages could introduce a breaking change to the package policy API if they change the input type. But I think it's a good stopgap solution if it's indeed true that there aren't duplicate inputs of the same type. Another option could be to only support packages that contain input IDs on the new API during the migration period to add IDs to package inputs. |
@joshdover I have a working API with key instead of array and it's a lot easier to use, I am wondering if all the inputs and streams should be disabled by default or if we should use package default, (I like the idea of using default) this mean the user can create a working integration with just something like this and then he can start to customize inputs by adding disabled by default one or disabling the default one it does not need
|
@mtojek @jsoriano what do you think of Kibana temporarly introducing an input id (like policy_template + input type) while it's implemented in the package (#132263 (comment)) do you think of package where this will not be working? |
Hi @nchaulet,
What do you mean by temporarily? I may not see the full picture.
To be honest, with current package scale it's hard to predict which packages may potentially break. I'm wondering if it doesn't affect elastic-package (system tests), but if it's just about populating when the property is missing, it should be safe, right? If you need 100% certainty, we could perform such an exercise (install every package). |
Hi @mtojek going to give more context we want to introduce a new API to create package policy much simpler for user something like this #132263 (comment) For this we need an id for each input, while this is adopted and implemented for each package elastic/package-spec#385 what I propose is we use a request to the API will be something like // POST /package-policies
{
"name": "nginx-test"
"inputs: {
"nginx-logfile": { // policy template - input type
"streams": {
"nginx.error": { // stream dataset
tags: ['test', 'nginx-error'], // variables as key:value
}
}
}
//... input variables optionnal
}
//... package variables optionnal
} |
After elastic/package-spec#385 is implemented, Fleet will still need to be able to handle current integrations that don't have this id. |
@nchaulet Could this be closed? |
Yes this should be closed |
While improvements in #119739 were made to make consuming the package_policies API simpler, by automatically providing default values for all fields possible, there are still several issues that make consuming this API hard for end-users. For example, see this API call to create an Apache package policy:
See UI for Apache integration
A few issues standout:
type
field. This would allow for aninputs
array like:The text was updated successfully, but these errors were encountered: