elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.62k stars 8.22k forks source link

[Fleet] Add default variables to all integration data streams #170336

Open kpollich opened 1 year ago

kpollich commented 1 year ago

Ref https://github.com/elastic/elastic-package/issues/949

There are several common variables that are defined across many integrations that have broad use cases and generic appeal to users, e.g.

These variables are almost always copy/pasted between various data streams that want to support them. This is a manual process, and incurs a maintenance burden for integrations that want to adopt these universally applicable variables. If we wanted to adopt these across all integrations today, we'd also need to publish a new version of every single integrations or accept a slow pace of adoption - neither of which is particularly appealing.

Instead, we should add logic to Fleet to append these fields to all data streams across all integrations.

When a user opens policy editor to create/edit a package policy, Fleet will check a hardcoded list of global variable definitions and append those variables to the policy editor section for each data stream.

The nginx integration's access dataset is a good example of what the "end state" would look like for all data streams:

image

The highlighted section of "advanced fields" are defined by the nginx integration, but with this change in Fleet they'd appear in the same spot for all data streams across all integrations.

There's a few open questions and caveats to consider, e.g:

To start, let's limit the approach here to only the processors variable. This will let us validate the approach and iron out any of the edge cases around upgrades, deferring to integration manifests, etc.

Proposed configuration schema

Each variable definition should conform to an object that extends the package spec's variable definition. However, we should enforce a few caveats for the v1 of this implementation in the interest of avoiding complexity:

interface DefaultIntegrationVariable {
  name: string;
  type: string;
  title: string;
  description: string;
  multi: boolean;
  default: any; // can probably do some TypeScript wizardry to make this typesafe
  data_stream_types: Array<"logs" | "metrics">
}
elasticmachine commented 1 year ago

Pinging @elastic/fleet (Team:Fleet)

ishleenk17 commented 1 year ago

The highlighted section of "advanced fields" are defined by the nginx integration, but with this change in Fleet they'd appear in the same spot for all data streams across all integrations.

@kpollich: Not all of these fields would be valid for all datastreams. For Eg: ignore_older,tags is true only for logs datastream.

kpollich commented 1 year ago

Thanks, @ishleenk17

Not all of these fields would be valid for all datastreams. For Eg: ignore_older,tags is true only for logs datastream.

We could define a baseline compatibility condition in Fleet by adding a condition to each variable definition like data_stream_types: [logs, metrics].

ishleenk17 commented 1 year ago

@kpollich : On the same lines as ignore_older, there is another variable "Preserve Original Events" which is meant to be present for all the logs datastream by default.

cc: @lalit-satapathy

kpollich commented 1 year ago

Thanks @ishleenk17, I've updated the description to capture that variable.

kpollich commented 12 months ago

@nimarezainia - Can you confirm that we're okay to start here with just the processors variable to validate the implementation? I think we had talked about reducing our scope here to just processors for now but would like to confirm. Thanks.

nimarezainia commented 12 months ago

@kpollich yes we should go with processors first. add_fields or add_tags can be used to achieve the tagging requirement if needed.