Skip to content

[Fleet] Allow to override data stream type in policies for input packages#214216

Merged
jsoriano merged 50 commits intoelastic:mainfrom
jsoriano:input-package-ds-type
May 26, 2025
Merged

[Fleet] Allow to override data stream type in policies for input packages#214216
jsoriano merged 50 commits intoelastic:mainfrom
jsoriano:input-package-ds-type

Conversation

@jsoriano
Copy link
Member

@jsoriano jsoriano commented Mar 12, 2025

Summary

Part of elastic/package-spec#849.

Allow to select the data stream type when creating policies for input packages. This will allow to benefit from presets related to specific signal types.

It adds the following selector as an advanced option:

imagen

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

How to test

  • Install an input package (input packages are the ones that have type: input in their manifests, such as sql or log packages).
  • Create a new policy for this input package.
  • When creating a new policy, open the advanced settings, and select a different data stream type from the default.
  • Check that an index policy has been created for this package, with the prefix of the selected data stream type.

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@jsoriano jsoriano self-assigned this Mar 12, 2025
@jsoriano jsoriano added backport:skip This PR does not require backporting Team:Fleet Team label for Observability Data Collection Fleet team labels Mar 12, 2025
@jsoriano
Copy link
Member Author

Almost everything is working here: the UI element works, its state is persisted in the policy, and the index templates are created as expected. But the type is not set in the agent policy, and agents using the policy don't ingest anything.

For example in this example data_stream should contain type: metrics IIUC:

    streams:
      - id: metrics-log.logs-d43daf00-344f-4378-9a45-ec84501addf9
        data_stream:
          dataset: test
        paths:
          - /tmp/foo*
        ignore_older: 72h

@jsoriano jsoriano force-pushed the input-package-ds-type branch from 486a493 to 698afc9 Compare April 24, 2025 14:58
@jsoriano jsoriano added the release_note:feature Makes this part of the condensed release notes label Apr 24, 2025
{
id: 'traces',
label: 'Traces',
},
Copy link
Member Author

@jsoriano jsoriano Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to allow all types for any input package?

In principle I would say so, it is up to the user to know what kind of data they are collecting.

If we think that some packages should be limited to only certain types, we would need to add something in the spec.

<EuiRadioGroup
data-test-subj="packagePolicyDataStreamType"
disabled={isEditPage}
idSelected={packagePolicyInputStream.data_stream.type || 'logs'}
Copy link
Member Author

@jsoriano jsoriano Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Package Spec requires a type now in policy templates in input packages.

Should we remove this requirement, now that the type can be configured?

As it is now here, this code will support streams without defined type, and will use logs as default, but older versions of kibana may not work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can probably remove this if we bump the max spec version available in kibana

@jsoriano jsoriano marked this pull request as ready for review April 24, 2025 17:47
@jsoriano jsoriano requested a review from a team as a code owner April 24, 2025 17:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

)
}
>
<EuiRadioGroup
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be probably nice to add some kind of E2E or integration test to check that this radio button works and that the expected index template is created after installing the package and adding a policy.

@juliaElastic @nchaulet wdyt? do you have recommendations about where to start adding such a test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.7MB 1.7MB +1.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 164.5KB 164.6KB +49.0B

History

cc @jsoriano

@jsoriano jsoriano merged commit 4337d10 into elastic:main May 26, 2025
11 checks passed
@jsoriano jsoriano deleted the input-package-ds-type branch May 26, 2025 16:44
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
…ages (elastic#214216)

Allow to select the data stream type when creating policies for input
packages.
It is only possible to select the data stream type when creating policies
and not when editing them.
The selector is added as an advanced option.
@jsoriano jsoriano added backport:prev-major and removed backport:skip This PR does not require backporting labels Jun 9, 2025
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.17, 8.18, 8.19

https://github.com/elastic/kibana/actions/runs/15543134795

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 9, 2025
…ages (elastic#214216)

Allow to select the data stream type when creating policies for input
packages.
It is only possible to select the data stream type when creating policies
and not when editing them.
The selector is added as an advanced option.

(cherry picked from commit 4337d10)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 9, 2025
…ages (elastic#214216)

Allow to select the data stream type when creating policies for input
packages.
It is only possible to select the data stream type when creating policies
and not when editing them.
The selector is added as an advanced option.

(cherry picked from commit 4337d10)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.17 Backport failed because of merge conflicts
8.18
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 214216

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 9, 2025
…ut packages (#214216) (#223151)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Fleet] Allow to override data stream type in policies for input
packages (#214216)](#214216)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jaime Soriano
Pastor","email":"jaime.soriano@elastic.co"},"sourceCommit":{"committedDate":"2025-05-26T16:44:19Z","message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Fleet","release_note:feature","backport:prev-major","v9.1.0"],"title":"[Fleet]
Allow to override data stream type in policies for input
packages","number":214216,"url":"https://github.com/elastic/kibana/pull/214216","mergeCommit":{"message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214216","number":214216,"mergeCommit":{"message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22"}}]}]
BACKPORT-->

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
kibanamachine added a commit that referenced this pull request Jun 9, 2025
…ut packages (#214216) (#223152)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Fleet] Allow to override data stream type in policies for input
packages (#214216)](#214216)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jaime Soriano
Pastor","email":"jaime.soriano@elastic.co"},"sourceCommit":{"committedDate":"2025-05-26T16:44:19Z","message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Fleet","release_note:feature","backport:prev-major","v9.1.0"],"title":"[Fleet]
Allow to override data stream type in policies for input
packages","number":214216,"url":"https://github.com/elastic/kibana/pull/214216","mergeCommit":{"message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214216","number":214216,"mergeCommit":{"message":"[Fleet]
Allow to override data stream type in policies for input packages
(#214216)\n\nAllow to select the data stream type when creating policies
for input\npackages.\nIt is only possible to select the data stream type
when creating policies\nand not when editing them.\nThe selector is
added as an advanced
option.","sha":"4337d10c215f0e87b2da746026f455e62ab60e22"}}]}]
BACKPORT-->

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
jsoriano added a commit that referenced this pull request Jun 10, 2025
… for input packages (#214216) (#223151)" (#223247)

This change was only intended to be backported to 8.19, backported by
mistake to 8.18 in #223151.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:feature Makes this part of the condensed release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.18.3 v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants