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

[APM] Adds 'Anomaly detection' settings page to create ML jobs per environment #70560

Merged
merged 15 commits into from
Jul 7, 2020

Conversation

ogupte
Copy link
Contributor

@ogupte ogupte commented Jul 2, 2020

Closes #70422.
Adds 'Anomaly detection' settings page along with required API endpoints to list and create the APM anomaly detection jobs per environment.

anomaly-detection-settings-0

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

Just a quick review for the copy mainly as I had updated it yesterday.

@formgeist formgeist requested a review from bmorelli25 July 2, 2020 09:28
@formgeist
Copy link
Contributor

@bmorelli25 Can you give the general copy a quick look and give your suggestion for improvements. This was written very quickly by yours truly, but I feel like it needs professional help 😊

@ogupte ogupte removed the blocked label Jul 2, 2020
@ogupte ogupte force-pushed the apm-70422-anomaly-detection-settings branch from 2ce5235 to 0c17927 Compare July 2, 2020 22:03
ogupte and others added 7 commits July 3, 2020 23:54
to list and create the apm anomaly detection jobs per environment.
Some test data is hardcoded while the the required changes in the ML
plugin are in flight.
in groups array. Also adds random token to the job ID to prevent
collisions for job ids where diffferent environment names convert to the
same string
…ML module

- Implements job list in settings by reading from `custom_settings.job_tags['service.environment']`
- Add ML module method `createModuleItem` for job configuration
- Don't allow user to type in duplicate environments
…ction/add_environments.tsx

Co-authored-by: Casper Hübertz <casper@formgeist.com>
…ction/index.tsx

Co-authored-by: Casper Hübertz <casper@formgeist.com>
- makes the 'all' environment name ALL_OPTION_VALUE agent configuration-specific
- replace field literals with constants
@ogupte ogupte force-pushed the apm-70422-anomaly-detection-settings branch from 417d01d to cb9a8ad Compare July 4, 2020 07:21
@ogupte ogupte marked this pull request as ready for review July 4, 2020 07:22
@ogupte ogupte requested review from a team as code owners July 4, 2020 07:22
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Jul 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Looks really good. Just a bunch of nits

Copy link
Member

@bmorelli25 bmorelli25 left a comment

Choose a reason for hiding this comment

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

A few text suggestions

… 'Not defined' option is disabled if it already exists.
@ogupte
Copy link
Contributor Author

ogupte commented Jul 7, 2020

@elasticmachine merge upstream

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

ML changes LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

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

@sorenlouv sorenlouv merged commit 7d44d02 into elastic:master Jul 7, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 7, 2020
* master:
  Rename legacy ES mock accessors (elastic#70432)
  [APM] Adds 'Anomaly detection' settings page to create ML jobs per environment (elastic#70560)
  Forbid timezones not working in Elasticsearch (elastic#70780)
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 7, 2020
…rbac

* alerting/consumer-based-rbac:
  Rename legacy ES mock accessors (elastic#70432)
  [APM] Adds 'Anomaly detection' settings page to create ML jobs per environment (elastic#70560)
  Forbid timezones not working in Elasticsearch (elastic#70780)
  [ML] Adding peak_model_bytes to model size stats type (elastic#70825)
sorenlouv pushed a commit to sorenlouv/kibana that referenced this pull request Jul 7, 2020
…vironment (elastic#70560)

* Adds 'Anomaly detection' settings page along with require API endpoints
to list and create the apm anomaly detection jobs per environment.
Some test data is hardcoded while the the required changes in the ML
plugin are in flight.

* Converts the environment name to a compatible ML id string and persist
in groups array. Also adds random token to the job ID to prevent
collisions for job ids where diffferent environment names convert to the
same string

* - Improve job creation with latest updates for the `apm_transaction` ML module
- Implements job list in settings by reading from `custom_settings.job_tags['service.environment']`
- Add ML module method `createModuleItem` for job configuration
- Don't allow user to type in duplicate environments

* Update x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/add_environments.tsx

Co-authored-by: Casper Hübertz <casper@formgeist.com>

* Update x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/index.tsx

Co-authored-by: Casper Hübertz <casper@formgeist.com>

* UX feedback, adds i18n, and handles failed state for ML jobs fetch.

* - Moves get_all_environments from agent_configuration dir to common dir
- makes the 'all' environment name ALL_OPTION_VALUE agent configuration-specific
- replace field literals with constants

* PR feedback

* Adds support to create jobs for environment which are not defined.

* Fixes description copy, rearranges settings links, and makes sure the 'Not defined' option is disabled if it already exists.

* Only show "Not defined" in environment selector if there are actually
documents without service.environment set

* get the indexPatternName for the ML job from the set of user-definned indices

* updated job_tags type definition

Co-authored-by: Casper Hübertz <casper@formgeist.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
};

export function convertToMLIdentifier(value: string) {
return value.replace(/\s+/g, '_').toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

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

@ogupte we should improve this

// remove non-alphanumeric characters
retur value.toLowerCase().replace(/[^a-z0-9+]+/g, '_');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i simplified this in another PR:

prefix: `${ML_GROUP_NAME_APM}-${snakeCase(environment)}-${randomToken}-`,
to just use the lodash function snakeCase. This also has the effect of deburring and removing all invalid chars

return [];
}
try {
const { jobs } = await ml.anomalyDetectors.jobs(ML_GROUP_NAME_APM);
Copy link
Member

@sorenlouv sorenlouv Jul 7, 2020

Choose a reason for hiding this comment

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

It just occurs to me that we are retrieving jobs without specifying that we are filtering by groups. Will this return for any field that matches ML_GROUP_NAME_APM?

I'd expect something like:

const { jobs } = await ml.anomalyDetectors.jobs({group: ML_GROUP_NAME_APM });

Similarly, if we want to retrieve jobs by job id:

const { jobs } = await ml.anomalyDetectors.job({ id: 'some-id' });

smith added a commit to smith/kibana that referenced this pull request Jul 8, 2020
Use "apm-*" to match the new job IDs added in elastic#70560.
smith added a commit that referenced this pull request Jul 9, 2020
* [APM] Update ML job ID in data telemetry tasks

Use "apm-*" to match the new job IDs added in #70560.

* additional fix

* Remove unused import
smith added a commit to smith/kibana that referenced this pull request Jul 9, 2020
* [APM] Update ML job ID in data telemetry tasks

Use "apm-*" to match the new job IDs added in elastic#70560.

* additional fix

* Remove unused import
smith added a commit that referenced this pull request Jul 9, 2020
Use "apm-*" to match the new job IDs added in #70560.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:APM All issues that need APM UI Team support v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Anomaly detection: Add Anomaly detection view in Settings
7 participants