Skip to content
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

[ML] Improve messaging and support for datafeed using aggregated and scripted fields #84594

Merged
merged 35 commits into from
Dec 10, 2020

Conversation

qn895
Copy link
Member

@qn895 qn895 commented Nov 30, 2020

Summary

This PR adds better messaging for unsupported configurations and improved support for aggregated and scripted fields. Changes include:

  1. Add better messaging on why some jobs cannot be viewed using the Single Metric Viewer
    Screen Shot 2020-11-30 at 15 13 26
    Screen Shot 2020-11-30 at 15 13 37

Screen Shot 2020-11-30 at 15 23 06
Screen Shot 2020-11-30 at 15 22 48

Screen Shot 2020-12-17 at 17 41 45

  1. Add ability to create and view job when datafeed uses something other than buckets in the datafeed's aggregation (e.g. an arbitrary name like 'my_buckets'). Previously, this is only supported via the API. This PR makes it so that the fields are listed correctly in the job creation wizard and makes the charts plot correctly.
    2020-11-30 at 17 31
    2020-11-30 at 17 32

  2. Ability to plot Anomaly Explorer charts for jobs with aggregated or scripted fields with model plot data in cases if source chart is not chartable.

  • Before
    Screen Shot 2020-11-30 at 17 17 46
  • After
    Screen Shot 2020-11-30 at 17 22 38
  1. Add fix to we can no longer click on disabled buttons

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@qn895 qn895 requested a review from lcawl November 30, 2020 23:33
'xpack.ml.timeSeriesJob.varyingBucketSpanAggregationInterval',
{
defaultMessage:
'bucket span and aggregation interval is not the same for datafeed with aggregation fields',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could be clarified a bit. For example:

           'the datafeed has aggregation fields and the aggregation interval is not the same as the bucket span',

or:

           'bucket span and aggregation interval are not the same for a datafeed with aggregation fields', 

I prefer the first suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

My vote goes to the first suggestion from @lcawl

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here 02a579b

'xpack.ml.timeSeriesJob.varyingBucketSpanAggregationInterval',
{
defaultMessage:
'bucket span and aggregation interval is not the same for datafeed with aggregation fields',
Copy link
Contributor

Choose a reason for hiding this comment

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

My vote goes to the first suggestion from @lcawl

x-pack/plugins/ml/common/util/job_utils.ts Show resolved Hide resolved
}

// if aggregation interval is different from bucket span
const datetimeBucket = aggs[aggBucketsName].date_histogram;
Copy link
Contributor

Choose a reason for hiding this comment

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

For this use case, I think we should enable access to the Single Metric Viewer, and show the charts in the Anomaly Explorer, but display a Toast / Callout which explains that the numbers on the chart may differ from the values reported for the anomaly. For example, this chart provides a lot of value:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Update - as discussed, we should just show the charts in this case, with no Toast / Callout about the differing bucket span and aggregation interval, as otherwise they would show up for jobs created in the Single Metric wizard, where we set the agg interval to 10% of the bucket span. We can address that edge case in a future PR, to show a toast warning only if the function used in the detector is different to that used in the datafeed aggregation.

// Returns a flag to indicate whether the job is suitable for viewing
// in the Time Series dashboard.
export function isTimeSeriesViewJob(job: CombinedJob): boolean {
export function isTimeSeriesViewableJob(job: CombinedJob): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that some of my jobs are greyed out in the job selector in the Single Metric Viewer when they shouldn't be. Is this because some of the logic in here is not quite correct? Jobs which don't use partitioning fields are being disabled here:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed here 15cc5ed

jobsErrorMessage[record.job_id] = i18n.translate(
'xpack.ml.timeSeriesJob.sourceDataModelPlotNotChartableMessage',
{
defaultMessage: 'both source data and model plot not chartable for this detector',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs are inserted, source data and model plot are not chartable

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here ce964f5

<EuiCallOut color={'warning'} size="s">
<FormattedMessage
id="xpack.ml.explorerCharts.errorCallOutMessage"
defaultMessage="You can't view anomaly records for {jobs} because {reason}."
Copy link
Contributor

Choose a reason for hiding this comment

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

Swap the word records for charts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here ce964f5

@qn895 qn895 requested a review from pheyos December 8, 2020 23:47
@qn895
Copy link
Member Author

qn895 commented Dec 8, 2020

As discussed I have updated a logic to be less strict so that it will not necessarily disable when there's nested term aggregations or when the bucket span != aggregation interval. This is so examples like below will still show up, without callouts, despite the anomaly markers not plotting correctly:

{
  "datafeed_id": "",
  "job_id": "",
  "indices": [
    "cloudwatch-*"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        }
      ]
    }
  },
  "aggregations": {
    "buckets": {
      "date_histogram": {
        "field": "@timestamp",
        "interval": "15m",
        "time_zone": "UTC"
      },
      "aggregations": {
        "@timestamp": {
          "max": {
            "field": "@timestamp"
          }
        },
        "instance": {
          "terms": {
            "field": "instance"
          },
          "aggs": {
            "DiskReadBytesSum": {
              "sum": {
                "field": "DiskReadBytes"
              }
            }
          }
        }
      }
    }
  }
}
  "analysis_config": {
    "bucket_span": "30m",
    "summary_count_field_name": "doc_count",
    "detectors": [
      {
        "detector_description": "mean DiskReadBytesSum partition instance",
        "function": "mean",
        "field_name": "DiskReadBytesSum",
        "partition_field_name": "instance",
        "detector_index": 0
      }
    ],
    "influencers": [
      "instance"
    ]
  },

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM, great you added some functional tests too! 👍

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested latest edits and LGTM!

@qn895
Copy link
Member Author

qn895 commented Dec 9, 2020

Started flaky test suite runner...

@qn895
Copy link
Member Author

qn895 commented Dec 10, 2020

Started flaky test suite runner...

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

Functional tests LGTM, thanks for adding them as part of this PR! 🎉
Just one small nit after the latest change, but feel free to merge as is if you want.

x-pack/test/functional/services/ml/job_selection.ts Outdated Show resolved Hide resolved
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1592 1593 +1

Async chunks

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

id before after diff
ml 5.2MB 5.3MB +2.8KB

Distributable file count

id before after diff
default 47010 47770 +760

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants