-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ML] Fixing results for unknown fields #24577
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
Merged
jgowdyelastic
merged 4 commits into
elastic:master
from
jgowdyelastic:fixing-results-for-unknown-fields
Oct 26, 2018
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |
| background-color: #920000; | ||
| } | ||
|
|
||
| .type-other { | ||
| .type-other, .unknown { | ||
| background-color: #bfa180; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...gins/ml/public/file_datavisualizer/components/experimental_badge/_experimental_badge.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .ml-experimental-badge.euiBetaBadge { | ||
| font-size: 10px; | ||
| vertical-align: middle; | ||
| margin-bottom: 5px; | ||
| padding: 0px 20px; | ||
| line-height: 20px; | ||
| } |
1 change: 1 addition & 0 deletions
1
x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/_index.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import 'experimental_badge' |
19 changes: 19 additions & 0 deletions
19
...plugins/ml/public/file_datavisualizer/components/experimental_badge/experimental_badge.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import { | ||
| EuiBetaBadge, | ||
| } from '@elastic/eui'; | ||
|
|
||
| export function ExperimentalBadge({ tooltipContent }) { | ||
| return ( | ||
| <span> | ||
| <EuiBetaBadge className="ml-experimental-badge" label="Experimental" tooltipContent={tooltipContent} /> | ||
| </span> | ||
| ); | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/ml/public/file_datavisualizer/components/experimental_badge/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
|
|
||
| export { ExperimentalBadge } from './experimental_badge'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ import React, { | |
| } from 'react'; | ||
|
|
||
| import { FieldStatsCard } from './field_stats_card'; | ||
| import { getFieldNames } from './get_field_names'; | ||
| import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types'; | ||
|
|
||
| export class FieldsStats extends Component { | ||
| constructor(props) { | ||
|
|
@@ -46,26 +48,24 @@ function createFields(results) { | |
| const { | ||
| mappings, | ||
| field_stats: fieldStats, | ||
| column_names: columnNames, | ||
| num_messages_analyzed: numMessagesAnalyzed, | ||
| timestamp_field: timestampField, | ||
| } = results; | ||
|
|
||
| if (mappings && fieldStats) { | ||
| // if columnNames exists (i.e delimited) use it for the field list | ||
| // so we get the same order | ||
| const tempFields = (columnNames !== undefined) ? columnNames : Object.keys(fieldStats); | ||
|
|
||
| return tempFields.map((fName) => { | ||
| if (fieldStats[fName] !== undefined) { | ||
| const field = { name: fName }; | ||
| const f = fieldStats[fName]; | ||
| const m = mappings[fName]; | ||
| const fieldNames = getFieldNames(results); | ||
|
|
||
| return fieldNames.map((name) => { | ||
| if (fieldStats[name] !== undefined) { | ||
| const field = { name }; | ||
| const f = fieldStats[name]; | ||
| const m = mappings[name]; | ||
|
|
||
| // sometimes the timestamp field is not in the mappings, and so our | ||
| // collection of fields will be missing a time field with a type of date | ||
| if (fName === timestampField && field.type === undefined) { | ||
| field.type = 'date'; | ||
| if (name === timestampField && field.type === undefined) { | ||
| field.type = ML_JOB_FIELD_TYPES.DATE; | ||
| } | ||
|
|
||
| if (f !== undefined) { | ||
|
|
@@ -83,8 +83,15 @@ function createFields(results) { | |
|
|
||
| return field; | ||
| } else { | ||
| // field is not in the field stats | ||
| // this could be the message field for a semi-structured log file or a | ||
| // field which the endpoint has not been able to work out any information for | ||
| const type = (mappings[name] && mappings[name].type === ML_JOB_FIELD_TYPES.TEXT) ? | ||
| ML_JOB_FIELD_TYPES.TEXT : ML_JOB_FIELD_TYPES.UNKNOWN; | ||
|
|
||
| return { | ||
| name: fName, | ||
| name: name, | ||
| type, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit 🕸 could be just |
||
| mean_value: 0, | ||
| count: 0, | ||
| cardinality: 0, | ||
|
|
||
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/ml/public/file_datavisualizer/components/fields_stats/get_field_names.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
|
|
||
| import { difference } from 'lodash'; | ||
|
|
||
| export function getFieldNames(results) { | ||
| const { | ||
| mappings, | ||
| field_stats: fieldStats, | ||
| column_names: columnNames, | ||
| } = results; | ||
|
|
||
| // if columnNames exists (i.e delimited) use it for the field list | ||
| // so we get the same order | ||
| const tempFields = (columnNames !== undefined) ? columnNames : Object.keys(fieldStats); | ||
|
|
||
|
|
||
| // there may be fields in the mappings which do not exist in the field_stats | ||
| // e.g. the message field for a semi-structured log file, as they have no stats. | ||
| // add any extra fields to the list | ||
| const differenceFields = difference(Object.keys(mappings), tempFields); | ||
|
|
||
| // except @timestamp | ||
| const timestampIndex = differenceFields.indexOf('@timestamp'); | ||
| if (timestampIndex !== -1) { | ||
| differenceFields.splice(timestampIndex, 1); | ||
| } | ||
|
|
||
| if (differenceFields.length) { | ||
| tempFields.push(...differenceFields); | ||
| } | ||
| return tempFields; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you apply a
classNamedirectly toEuiBetaBadgeto achieve the same result here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the css would need to be in a shared location. so i decided it would be easier to just create a shared component instead to make it obvious that it's being overridden.