[ML] Adding missing text fields to advanced wizard (#49057) (#49191)

* [ML] Adding missing text fields to advanced wizard

* removing comment out code
This commit is contained in:
James Gowdy 2019-10-24 16:43:10 +01:00 committed by GitHub
parent 74f4281802
commit 275f982384
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 972 additions and 557 deletions

View file

@ -26,7 +26,9 @@ export const CategorizationFieldSelect: FC<Props> = ({ fields, changeHandler, se
const options: EuiComboBoxOptionProps[] = [
...createFieldOptions(
fields,
f => f.id !== EVENT_RATE_FIELD_ID && f.type === ES_FIELD_TYPES.KEYWORD
f =>
f.id !== EVENT_RATE_FIELD_ID &&
(f.type === ES_FIELD_TYPES.KEYWORD || f.type === ES_FIELD_TYPES.TEXT)
),
...createScriptFieldOptions(jobCreator.scriptFields),
];

View file

@ -0,0 +1,905 @@
{
"cloudwatch-*": {
"aggs": [
{
"id": "count",
"title": "Count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "high_count",
"title": "High count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "low_count",
"title": "Low count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "mean",
"title": "Mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_mean",
"title": "High mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_mean",
"title": "Low mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "sum",
"title": "Sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_sum",
"title": "High sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_sum",
"title": "Low sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "median",
"title": "Median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_median",
"title": "High median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_median",
"title": "Low median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "min",
"title": "Min",
"kibanaName": "min",
"dslName": "min",
"type": "metrics",
"mlModelPlotAgg": {
"max": "min",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "max",
"title": "Max",
"kibanaName": "max",
"dslName": "max",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "max"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "distinct_count",
"title": "Distinct count",
"kibanaName": "cardinality",
"dslName": "cardinality",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"instance",
"region",
"sourcetype.keyword",
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "non_zero_count",
"title": "Non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "high_non_zero_count",
"title": "High non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "low_non_zero_count",
"title": "Low non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "high_distinct_count",
"title": "High distinct count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"instance",
"region",
"sourcetype.keyword",
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_distinct_count",
"title": "Low distinct count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"instance",
"region",
"sourcetype.keyword",
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "metric",
"title": "Metric",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "varp",
"title": "varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_varp",
"title": "High varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_varp",
"title": "Low varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "non_null_sum",
"title": "Non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_non_null_sum",
"title": "High non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_non_null_sum",
"title": "Low non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "rare",
"title": "Rare",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "freq_rare",
"title": "Freq rare",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "info_content",
"title": "Info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "high_info_content",
"title": "High info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "low_info_content",
"title": "Low info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
},
{
"id": "time_of_day",
"title": "Time of day",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "time_of_week",
"title": "Time of week",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
}
},
{
"id": "lat_long",
"title": "Lat long",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"CPUUtilization",
"DiskReadBytes",
"DiskReadOps",
"DiskWriteBytes",
"DiskWriteOps",
"NetworkIn",
"NetworkOut"
]
}
],
"fields": [
{
"id": "@timestamp",
"name": "@timestamp",
"type": "date",
"aggregatable": true,
"aggIds": []
},
{
"id": "CPUUtilization",
"name": "CPUUtilization",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "DiskReadBytes",
"name": "DiskReadBytes",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "DiskReadOps",
"name": "DiskReadOps",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "DiskWriteBytes",
"name": "DiskWriteBytes",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "DiskWriteOps",
"name": "DiskWriteOps",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "instance",
"name": "instance",
"type": "keyword",
"aggregatable": true,
"aggIds": [
"distinct_count",
"high_distinct_count",
"low_distinct_count"
]
},
{
"id": "NetworkIn",
"name": "NetworkIn",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "NetworkOut",
"name": "NetworkOut",
"type": "double",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
},
{
"id": "region",
"name": "region",
"type": "keyword",
"aggregatable": true,
"aggIds": [
"distinct_count",
"high_distinct_count",
"low_distinct_count"
]
},
{
"id": "sourcetype",
"name": "sourcetype",
"type": "text",
"aggregatable": false,
"aggIds": []
},
{
"id": "sourcetype.keyword",
"name": "sourcetype.keyword",
"type": "keyword",
"aggregatable": true,
"aggIds": [
"distinct_count",
"high_distinct_count",
"low_distinct_count"
]
}
]
}
}

View file

@ -1,528 +0,0 @@
{
"farequote-*": {
"aggs": [
{
"id": "count",
"title": "Count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "high_count",
"title": "High count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "low_count",
"title": "Low count",
"kibanaName": "count",
"dslName": "count",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "mean",
"title": "Mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_mean",
"title": "High mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_mean",
"title": "Low mean",
"kibanaName": "avg",
"dslName": "avg",
"type": "metrics",
"mlModelPlotAgg": {
"max": "avg",
"min": "avg"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "sum",
"title": "Sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_sum",
"title": "High sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_sum",
"title": "Low sum",
"kibanaName": "sum",
"dslName": "sum",
"type": "metrics",
"mlModelPlotAgg": {
"max": "sum",
"min": "sum"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "median",
"title": "Median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_median",
"title": "High median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_median",
"title": "Low median",
"kibanaName": "median",
"dslName": "percentiles",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "min",
"title": "Min",
"kibanaName": "min",
"dslName": "min",
"type": "metrics",
"mlModelPlotAgg": {
"max": "min",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "max",
"title": "Max",
"kibanaName": "max",
"dslName": "max",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "max"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "distinct_count",
"title": "Distinct count",
"kibanaName": "cardinality",
"dslName": "cardinality",
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"airline",
"responsetime"
]
},
{
"id": "non_zero_count",
"title": "Non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "high_non_zero_count",
"title": "High non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "low_non_zero_count",
"title": "Low non zero count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "high_distinct_count",
"title": "High distinct count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_distinct_count",
"title": "Low distinct count",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "metric",
"title": "Metric",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "varp",
"title": "varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_varp",
"title": "High varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_varp",
"title": "Low varp",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "non_null_sum",
"title": "Non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_non_null_sum",
"title": "High non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_non_null_sum",
"title": "Low non null sum",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "rare",
"title": "Rare",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "freq_rare",
"title": "Freq rare",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "info_content",
"title": "Info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "high_info_content",
"title": "High info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "low_info_content",
"title": "Low info content",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
},
{
"id": "time_of_day",
"title": "Time of day",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "time_of_week",
"title": "Time of week",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": []
},
{
"id": "lat_long",
"title": "Lat long",
"kibanaName": null,
"dslName": null,
"type": "metrics",
"mlModelPlotAgg": {
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
}
],
"fields": [
{
"id": "@timestamp",
"name": "@timestamp",
"type": "date",
"aggregatable": true,
"aggIds": []
},
{
"id": "airline",
"name": "airline",
"type": "keyword",
"aggregatable": true,
"aggIds": [
"distinct_count"
]
},
{
"id": "responsetime",
"name": "responsetime",
"type": "float",
"aggregatable": true,
"aggIds": [
"mean",
"high_mean",
"low_mean",
"sum",
"high_sum",
"low_sum",
"median",
"high_median",
"low_median",
"min",
"max",
"distinct_count",
"high_distinct_count",
"low_distinct_count",
"metric",
"varp",
"high_varp",
"low_varp",
"non_null_sum",
"high_non_null_sum",
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
]
}
]
}
}

View file

@ -9,40 +9,60 @@ import { IndexPattern } from 'ui/index_patterns';
// there is magic happening here. starting the include name with `mock..`
// ensures it can be lazily loaded by the jest.mock function below.
import mockFarequoteResponse from './__mocks__/farequote_job_caps_response.json';
import mockCloudwatchResponse from './__mocks__/cloudwatch_job_caps_response.json';
jest.mock('./ml_api_service', () => ({
ml: {
jobs: {
newJobCaps: jest.fn(() => Promise.resolve(mockFarequoteResponse)),
newJobCaps: jest.fn(() => Promise.resolve(mockCloudwatchResponse)),
},
},
}));
const indexPattern = ({
id: 'farequote-*',
title: 'farequote-*',
id: 'cloudwatch-*',
title: 'cloudwatch-*',
} as unknown) as IndexPattern;
describe('new_job_capabilities_service', () => {
describe('farequote newJobCaps()', () => {
describe('cloudwatch newJobCaps()', () => {
it('can construct job caps objects from endpoint json', async done => {
await newJobCapsService.initializeFromIndexPattern(indexPattern);
const { fields, aggs } = await newJobCapsService.newJobCaps;
const responseTimeField = fields.find(f => f.id === 'responsetime') || { aggs: [] };
const airlineField = fields.find(f => f.id === 'airline') || { aggs: [] };
const networkOutField = fields.find(f => f.id === 'NetworkOut') || { aggs: [] };
const regionField = fields.find(f => f.id === 'region') || { aggs: [] };
const meanAgg = aggs.find(a => a.id === 'mean') || { fields: [] };
const distinctCountAgg = aggs.find(a => a.id === 'distinct_count') || { fields: [] };
expect(fields).toHaveLength(4);
expect(fields).toHaveLength(12);
expect(aggs).toHaveLength(35);
expect(responseTimeField.aggs).toHaveLength(25);
expect(airlineField.aggs).toHaveLength(1);
expect(networkOutField.aggs).toHaveLength(25);
expect(regionField.aggs).toHaveLength(3);
expect(meanAgg.fields).toHaveLength(7);
expect(distinctCountAgg.fields).toHaveLength(10);
done();
});
it('job caps including text fields', async done => {
await newJobCapsService.initializeFromIndexPattern(indexPattern, true, false);
const { fields, aggs } = await newJobCapsService.newJobCaps;
expect(fields).toHaveLength(13); // one more field
expect(aggs).toHaveLength(35);
done();
});
it('job caps excluding event rate', async done => {
await newJobCapsService.initializeFromIndexPattern(indexPattern, false, true);
const { fields, aggs } = await newJobCapsService.newJobCaps;
expect(fields).toHaveLength(11); // one less field
expect(aggs).toHaveLength(35);
expect(meanAgg.fields).toHaveLength(1);
expect(distinctCountAgg.fields).toHaveLength(2);
done();
});
});

View file

@ -50,15 +50,10 @@ export function loadNewJobCapabilities(
const categoryFieldTypes = [ES_FIELD_TYPES.TEXT, ES_FIELD_TYPES.KEYWORD, ES_FIELD_TYPES.IP];
class NewJobCapsService {
private _fields: Field[];
private _aggs: Aggregation[];
private _includeEventRateField: boolean;
constructor(includeEventRateField = true) {
this._fields = [];
this._aggs = [];
this._includeEventRateField = includeEventRateField;
}
private _fields: Field[] = [];
private _aggs: Aggregation[] = [];
private _includeEventRateField: boolean = true;
private _removeTextFields: boolean = true;
public get fields(): Field[] {
return this._fields;
@ -79,8 +74,15 @@ class NewJobCapsService {
return this._fields.filter(f => categoryFieldTypes.includes(f.type));
}
public async initializeFromIndexPattern(indexPattern: IndexPattern) {
public async initializeFromIndexPattern(
indexPattern: IndexPattern,
includeEventRateField = true,
removeTextFields = true
) {
try {
this._includeEventRateField = includeEventRateField;
this._removeTextFields = removeTextFields;
const resp = await ml.jobs.newJobCaps(indexPattern.title, indexPattern.type === 'rollup');
const { fields, aggs } = createObjects(resp, indexPattern.title);
@ -88,7 +90,10 @@ class NewJobCapsService {
addEventRateField(aggs, fields);
}
this._fields = fields;
// remove any text fields which have a keyword equivalents
const processedFields = this._removeTextFields ? processTextFields(fields) : fields;
this._fields = processedFields;
this._aggs = aggs;
} catch (error) {
console.error('Unable to load new job capabilities', error); // eslint-disable-line no-console
@ -199,4 +204,14 @@ function addEventRateField(aggs: Aggregation[], fields: Field[]) {
fields.splice(0, 0, eventRateField);
}
// remove fields which are text and have a keyword equivalent
function processTextFields(fields: Field[]) {
const keywordIds = fields.filter(f => f.type === ES_FIELD_TYPES.KEYWORD).map(f => f.id);
return fields.filter(
f =>
f.type !== ES_FIELD_TYPES.TEXT ||
(f.type === ES_FIELD_TYPES.TEXT && keywordIds.includes(`${f.id}.keyword`) === false)
);
}
export const newJobCapsService = new NewJobCapsService();

View file

@ -136,7 +136,8 @@ async function combineFieldsAndAggs(
const numericalFields = getNumericalFields(fields);
const ipFields = getIpFields(fields);
const mix = mixFactory(rollupFields);
const isRollup = Object.keys(rollupFields).length > 0;
const mix = mixFactory(isRollup, rollupFields);
aggs.forEach(a => {
if (a.type === METRIC_AGG_TYPE && a.fields !== undefined) {
@ -165,7 +166,7 @@ async function combineFieldsAndAggs(
return {
aggs,
fields: filterFields(fields),
fields: isRollup ? filterFields(fields) : fields,
};
}
@ -178,9 +179,7 @@ function filterFields(fields: Field[]): Field[] {
// returns a mix function that is used to cross-reference aggs and fields.
// wrapped in a provider to allow filtering based on rollup job capabilities
function mixFactory(rollupFields: RollupFields) {
const isRollup = Object.keys(rollupFields).length > 0;
function mixFactory(isRollup: boolean, rollupFields: RollupFields) {
return function mix(field: Field, agg: Aggregation): void {
if (
isRollup === false ||

View file

@ -66,7 +66,9 @@ describe('job_service - job_caps', () => {
expect(response).toEqual(farequoteJobCapsEmpty);
done();
});
});
describe('cloudwatch newJobCaps()', () => {
it('can get rollup job caps for rollup index pattern', async done => {
const indexPattern = 'cloud_roll_index';
const isRollup = true;