🌊 Streams: Use better default field#217478
Conversation
|
/ci |
|
/ci |
|
Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs) |
thomheymann
left a comment
There was a problem hiding this comment.
Looks good but would add a few tests for the detection logic (see below)
...ugins/shared/streams_app/public/components/data_management/stream_detail_enrichment/utils.ts
Show resolved
Hide resolved
|
@flash1293 a couple of things:
// selectors.tsx
export const selectDefaultField = createSelector(
[(context: SimulationContext) => context.samples],
(samples) => getDefaultTextField(samples)
);
// then in the components
const defaultFied = useSimulatorSelector((snapshot) => selectDefaultField(snapshot.context));
const formState = { ...getDefaultFormStateByType(type), field: defaultFied };The changes would be minimal, and we don't need to change anything on the existing
|
|
@tonyghiani I thought about this, but a good suggestion depends on the processor (e.g. for the date processor we wouldn't suggest the same fields). It's not even a given that all processors have a field to operate on. It could still be kept in the component, but it seems like it doesn't belong there.
Not sure, that would work too. I thought it's always nice to stay consistent and base all decisions on what the user currently sees so they can understand where things are coming from. |
Agree, the approach I was proposing would still work well since we have the processor type in scope // selectors.tsx
export const selectDefaultField = createSelector(
[
(context: SimulationContext) => context.samples,
(type: ProcessorType) => type
],
(samples, type) => getDefaultTextField(samples, type)
);
// then in the components
const defaultFied = useSimulatorSelector((snapshot) => selectDefaultField(snapshot.context, type));
const formState = { ...getDefaultFormStateByType(type), field: defaultFied }; |
|
Right, I see - no strong opinion, I can change it like that |
💚 Build Succeeded
Metrics [docs]Async chunks
History
|
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/14469423743 |
This PR passes the current sample documents to the default form state generation for new processors to pick a good default field. The logic that's actually employed for `dissect` and `grok` is the following: * Go through all docs and order string fields occurring by how many values they have * Pick the top one from a list of "well known" fields that probably make sense (in case of a tie, go by a the ordering of the well known fields) * If no field is found this way, just leave it empty - this still shows the full table and the user can pick the field they care about Especially for otel this should be helpful. (cherry picked from commit e6cdba6)
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
2 similar comments
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
This PR passes the current sample documents to the default form state generation for new processors to pick a good default field. The logic that's actually employed for `dissect` and `grok` is the following: * Go through all docs and order string fields occurring by how many values they have * Pick the top one from a list of "well known" fields that probably make sense (in case of a tie, go by a the ordering of the well known fields) * If no field is found this way, just leave it empty - this still shows the full table and the user can pick the field they care about Especially for otel this should be helpful. (cherry picked from commit e6cdba6)
# Backport This will backport the following commits from `main` to `8.19`: - [🌊 Streams: Use better default field (#217478)](#217478) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Joe Reuter","email":"johannes.reuter@elastic.co"},"sourceCommit":{"committedDate":"2025-04-15T12:29:09Z","message":"🌊 Streams: Use better default field (#217478)\n\nThis PR passes the current sample documents to the default form state\ngeneration for new processors to pick a good default field.\n\nThe logic that's actually employed for `dissect` and `grok` is the\nfollowing:\n* Go through all docs and order string fields occurring by how many\nvalues they have\n* Pick the top one from a list of \"well known\" fields that probably make\nsense (in case of a tie, go by a the ordering of the well known fields)\n* If no field is found this way, just leave it empty - this still shows\nthe full table and the user can pick the field they care about\n\nEspecially for otel this should be helpful.","sha":"e6cdba65ed8263cf0ffcd2ba6b14d7caa579432b","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","Team:obs-ux-logs","backport:version","Feature:Streams","v9.1.0","v8.19.0"],"title":"🌊 Streams: Use better default field","number":217478,"url":"https://github.com/elastic/kibana/pull/217478","mergeCommit":{"message":"🌊 Streams: Use better default field (#217478)\n\nThis PR passes the current sample documents to the default form state\ngeneration for new processors to pick a good default field.\n\nThe logic that's actually employed for `dissect` and `grok` is the\nfollowing:\n* Go through all docs and order string fields occurring by how many\nvalues they have\n* Pick the top one from a list of \"well known\" fields that probably make\nsense (in case of a tie, go by a the ordering of the well known fields)\n* If no field is found this way, just leave it empty - this still shows\nthe full table and the user can pick the field they care about\n\nEspecially for otel this should be helpful.","sha":"e6cdba65ed8263cf0ffcd2ba6b14d7caa579432b"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217478","number":217478,"mergeCommit":{"message":"🌊 Streams: Use better default field (#217478)\n\nThis PR passes the current sample documents to the default form state\ngeneration for new processors to pick a good default field.\n\nThe logic that's actually employed for `dissect` and `grok` is the\nfollowing:\n* Go through all docs and order string fields occurring by how many\nvalues they have\n* Pick the top one from a list of \"well known\" fields that probably make\nsense (in case of a tie, go by a the ordering of the well known fields)\n* If no field is found this way, just leave it empty - this still shows\nthe full table and the user can pick the field they care about\n\nEspecially for otel this should be helpful.","sha":"e6cdba65ed8263cf0ffcd2ba6b14d7caa579432b"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This PR passes the current sample documents to the default form state generation for new processors to pick a good default field.
The logic that's actually employed for
dissectandgrokis the following:Especially for otel this should be helpful.