Add new field migrate_from to handle inputs migration#1021
Add new field migrate_from to handle inputs migration#1021jsoriano merged 8 commits intoelastic:mainfrom
Conversation
spec/changelog.yml
Outdated
| - description: Allow otelcol input type and dynamic_signal_types field in integration packages. | ||
| type: enhancement | ||
| link: https://github.com/elastic/package-spec/pull/1091 | ||
| - description: Add definition for migrate_from field. |
There was a problem hiding this comment.
nit:
| - description: Add definition for migrate_from field. | |
| - description: Add support for migrating input types at integrations policy templates and data streams. |
| - ["default"] | ||
| - ["agentless"] | ||
| - ["default", "agentless"] | ||
| migrate_from: |
There was a problem hiding this comment.
can we add this to a definition at the integrations spec and use the ref in both places?
| "good_migrate_from": {}, | ||
| "bad_migrate_from": { | ||
| "manifest.yml", | ||
| []string{`field policy_templates.0.inputs.0: Additional property migrate_from is not allowed`}, |
There was a problem hiding this comment.
other than being present as a property, should the text be validated with some pattern?
There was a problem hiding this comment.
That's a good question. I didn't add any because it could match very different cases. For example, it could be an input type identifiers likelogfile, filestream, httpjson, cel, winlog, udp, tcp, aws/metrics, but I didn't find a definition of these anywhere in this repo. Do you have suggestions on how to match them? I thought of a regex but I don't know it it's the right choice.
There was a problem hiding this comment.
I found (via AI) the field is validated in runtime by elastic-agent, as values come from different sources. So if the value is not valid an error will rise at elastic-agent. I got cursor to go through all the input types on the current packages and come with a common regex:
Proposed Regex
^[a-z0-9][a-z0-9_\-]*(/[a-z0-9][a-z0-9_\-]*)*$Explanation:
[a-z0-9] — must start with alphanumeric (lowercase)
[a-z0-9_-]* — segment continues with alphanumeric, underscore, or hyphen
(/[a-z0-9][a-z0-9_-]) — optional additional segments after / (e.g., provider/type)Matches: filestream, azure-eventhub, cloudbeat/cis_k8s, log_file, prometheus/metrics
Rejects: empty string, Azure-EventHub (uppercase), //double, leading/trailing slashes
After learning this, i think is better to leave it open and delegate this validation (format/value) to the elastic-agent where there is the "source of truth", as introducing the regex could cause some false negatives... 👍🏻 wdyt?
There was a problem hiding this comment.
yes, I also got this regex but thought that is not the best way. It's basically a generic string validation, so it wouldn't add much value.
spec/changelog.yml
Outdated
| - description: Allow otelcol input type and dynamic_signal_types field in integration packages. | ||
| type: enhancement | ||
| link: https://github.com/elastic/package-spec/pull/1091 | ||
| - description: Add definition for migrate_from field. |
There was a problem hiding this comment.
if this depends on fleet/kibana PR, can we add it as a comment
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a temporary Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@test/packages/bad_migrate_from/data_stream/logs/elasticsearch/ingest_pipeline/default.yml`:
- Around line 4-7: The ingest pipeline step with tag "set_dataset" erroneously
sets field "data_stream.dataset" to "good_migrate_from.logs"; update that value
to "bad_migrate_from.logs" so this package routes documents to its own
dataset/index (locate the "set" block with tag: set_dataset and change the value
property accordingly).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f68e4bbc-b2a4-4f0e-af3c-044fa27e21ea
⛔ Files ignored due to path filters (4)
test/packages/bad_migrate_from/img/sample-logo.svgis excluded by!**/*.svgtest/packages/bad_migrate_from/img/sample-screenshot.pngis excluded by!**/*.pngtest/packages/good_migrate_from/img/sample-logo.svgis excluded by!**/*.svgtest/packages/good_migrate_from/img/sample-screenshot.pngis excluded by!**/*.png
📒 Files selected for processing (24)
code/go/pkg/validator/validator_test.gospec/changelog.ymlspec/integration/data_stream/manifest.spec.ymlspec/integration/manifest.spec.ymltest/packages/bad_migrate_from/LICENSE.txttest/packages/bad_migrate_from/_dev/build/docs/README.mdtest/packages/bad_migrate_from/changelog.ymltest/packages/bad_migrate_from/data_stream/logs/agent/stream/filestream.yml.hbstest/packages/bad_migrate_from/data_stream/logs/elasticsearch/ingest_pipeline/default.ymltest/packages/bad_migrate_from/data_stream/logs/fields/base-fields.ymltest/packages/bad_migrate_from/data_stream/logs/manifest.ymltest/packages/bad_migrate_from/docs/README.mdtest/packages/bad_migrate_from/manifest.ymltest/packages/bad_migrate_from/sample_event.jsontest/packages/good_migrate_from/LICENSE.txttest/packages/good_migrate_from/_dev/build/docs/README.mdtest/packages/good_migrate_from/changelog.ymltest/packages/good_migrate_from/data_stream/logs/agent/stream/filestream.yml.hbstest/packages/good_migrate_from/data_stream/logs/elasticsearch/ingest_pipeline/default.ymltest/packages/good_migrate_from/data_stream/logs/fields/base-fields.ymltest/packages/good_migrate_from/data_stream/logs/manifest.ymltest/packages/good_migrate_from/docs/README.mdtest/packages/good_migrate_from/manifest.ymltest/packages/good_migrate_from/sample_event.json
test/packages/bad_migrate_from/data_stream/logs/elasticsearch/ingest_pipeline/default.yml
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
History
cc @criamico |
| - op: remove | ||
| path: "/properties/policy_templates/items/properties/inputs/items/properties/migrate_from" | ||
| - op: remove | ||
| path: "/definitions/migrate_from" |
There was a problem hiding this comment.
Nit. This should go on top. Though this is relevant when removing elements from lists, that we are not doing on this version. So in this case it doesn't matter, and can stay here.
Related to elastic/package-spec#956 Package-spec PR: elastic/package-spec#1021 ## Summary Migrate inputs and vars when `migrate_from` field is found. **Please note:** for some integrations this migration path will require a change at elastic agent level. See elastic/package-spec#956 (comment) - Enable the new input and carries over its values from the old one - Inputs and variables that were enabled are now carried to the new version; however the state is maintained: if a variable is disabled, it stays disabled - Modified the secret handling so the existing secret references get carried over to the new inputs - Verified that this logic only run on package policy upgrade, when there is migrate_from present and Fleet detects a difference in input type - Add visual information about the migration Example with a test integration: https://github.com/user-attachments/assets/aaa56904-05d7-47b2-955b-5ae7a2c26c97 ### Testing This was tested with a test version of sentinelOne (not finalized yet): https://github.com/elastic/integrations/compare/main...kcreddy:sentinel_one-migrate-inputs?expand=1 ### Screenshots <img width="1641" height="1540" alt="Screenshot 2026-03-19 at 17 07 17" src="https://github.com/user-attachments/assets/819e46cd-823a-47df-8ef2-4fbce8900b53" /> <img width="1628" height="1524" alt="Screenshot 2026-03-19 at 17 07 43" src="https://github.com/user-attachments/assets/c5f97183-bcfd-496a-9882-e170323246e3" /> ### Checklist Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Related to elastic/package-spec#956 Package-spec PR: elastic/package-spec#1021 ## Summary Migrate inputs and vars when `migrate_from` field is found. **Please note:** for some integrations this migration path will require a change at elastic agent level. See elastic/package-spec#956 (comment) - Enable the new input and carries over its values from the old one - Inputs and variables that were enabled are now carried to the new version; however the state is maintained: if a variable is disabled, it stays disabled - Modified the secret handling so the existing secret references get carried over to the new inputs - Verified that this logic only run on package policy upgrade, when there is migrate_from present and Fleet detects a difference in input type - Add visual information about the migration Example with a test integration: https://github.com/user-attachments/assets/aaa56904-05d7-47b2-955b-5ae7a2c26c97 ### Testing This was tested with a test version of sentinelOne (not finalized yet): https://github.com/elastic/integrations/compare/main...kcreddy:sentinel_one-migrate-inputs?expand=1 ### Screenshots <img width="1641" height="1540" alt="Screenshot 2026-03-19 at 17 07 17" src="https://github.com/user-attachments/assets/819e46cd-823a-47df-8ef2-4fbce8900b53" /> <img width="1628" height="1524" alt="Screenshot 2026-03-19 at 17 07 43" src="https://github.com/user-attachments/assets/c5f97183-bcfd-496a-9882-e170323246e3" /> ### Checklist Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
What does this PR do?
Add a new
migrate_fromfield that can be used to auto-migrate equivalent inputs or streams on Fleet side. An example is migratinghttpjsontocel. The field can be added at two levels:Example 1 - policy template
Example 2 - streams
Please note: for some integrations this migration path will require a change at elastic agent level, so package authors should consider carefully if it's safe to use it. See comment
Why is it important?
Checklist
test/packagesthat prove my change is effective.spec/changelog.yml.Related issues