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] APM Latency Correlations: Field/value candidates prioritization #107370

Merged

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Aug 2, 2021

Summary

Part of #106381

  • Makes sure fields defined in FIELDS_TO_ADD_AS_CANDIDATE and prefixed with one of FIELD_PREFIX_TO_ADD_AS_CANDIDATE get queried first when retrieving the correlation and ks-test value.
  • Correctly consider the includeFrozen parameter.
  • The bulk of the PR is a refactor:
    • Moves query_* files to queries directory
    • Introduces asyncSearchServiceStateProvider to manage the state of the async search service in isolation so that we no longer mutate individual vars or plain objects.
    • Introduces asyncSearchServiceLogProvider and extends the log to not only store messages but original error messages retrieved from ES too.
    • Refactors some more functions in separate files and adds unit tests.
    • Removes some deprecated code no longer needed.

Checklist

@walterra walterra self-assigned this Aug 2, 2021
@walterra walterra force-pushed the ml-apm-correlations-field-priorization branch from 201dd65 to 3964729 Compare August 2, 2021 10:14
@walterra walterra force-pushed the ml-apm-correlations-field-priorization branch from 6c0a11f to 78362e3 Compare August 2, 2021 13:29
@walterra walterra marked this pull request as ready for review August 2, 2021 14:56
@walterra walterra requested a review from a team as a code owner August 2, 2021 14:56
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@elasticmachine
Copy link
Contributor

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

@walterra walterra requested a review from qn895 August 2, 2021 14:57
if (
params === undefined ||
item === undefined ||
state.getState().isCancelled
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is used a few times inside this for loop it might make sense to assign it to a variable outside the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The process could have been cancelled by the user in parallel while the for loop is still running, that's why we always need to check for the latest state of isCancelled, if we assign it once outside the loop it could be out of date. I added a helper getter so we can use state.getIsCancelled() in af7afce to simplify the usage a bit.

@qn895
Copy link
Member

qn895 commented Aug 3, 2021

LGTM, just left a few comments 🎉 Tested the overall behavior and everything looks good, will look into testing the new includeFrozen option.

@@ -48,17 +48,17 @@ export const fetchTransactionDurationFieldValuePairs = async (
esClient: ElasticsearchClient,
params: SearchServiceFetchParams,
fieldCandidates: Field[],
progress: AsyncSearchProviderProgress
state: AsyncSearchServiceState
): Promise<FieldValuePairs> => {
const fieldValuePairs: FieldValuePairs = [];

let fieldValuePairsProgress = 1;

for (let i = 0; i < fieldCandidates.length; i++) {
Copy link
Member

@sorenlouv sorenlouv Aug 4, 2021

Choose a reason for hiding this comment

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

Perhaps this would become easier to read if you create a utility function that makes it explicit that we want to iterate sequentially through the array (as opposed to doing it in parallel with arr.map):

async function runInSequence(items, fn) {
  const results = [];

  for (const item of items) {
    results.push(await fn(item));
  }

  return results;
}

And using it like:

const fieldValuePairs = runInSequence(fieldCandidates, async (fieldName) => {
	
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, refactored in dd7636c.

@walterra
Copy link
Contributor Author

walterra commented Aug 9, 2021

@elasticmachine merge upstream

@walterra
Copy link
Contributor Author

walterra commented Aug 9, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / general / Chrome UI Functional Tests.test/functional/apps/management/_index_pattern_create_delete·js.management creating and deleting default index validation can display errors

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 11 times on tracked branches: https://github.com/elastic/kibana/issues/107831

[00:00:00]       │
[00:00:00]         └-: management
[00:00:00]           └-> "before all" hook in "management"
[00:00:00]           └-> "before all" hook in "management"
[00:00:00]             │ info [test/functional/fixtures/es_archiver/logstash_functional] Unloading indices from "mappings.json"
[00:00:00]             │ info [test/functional/fixtures/es_archiver/logstash_functional] Unloading indices from "data.json.gz"
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Loading "mappings.json"
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Loading "data.json.gz"
[00:00:01]             │ info [o.e.c.m.MetadataCreateIndexService] [node-01] [logstash-2015.09.17] creating index, cause [api], templates [], shards [1]/[0]
[00:00:01]             │ info [o.e.c.r.a.AllocationService] [node-01] current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[logstash-2015.09.17][0]]])." previous.health="YELLOW" reason="shards started [[logstash-2015.09.17][0]]"
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Created index "logstash-2015.09.17"
[00:00:01]             │ debg [test/functional/fixtures/es_archiver/makelogs] "logstash-2015.09.17" settings {"index":{"analysis":{"analyzer":{"url":{"max_token_length":"1000","tokenizer":"uax_url_email","type":"standard"}}},"number_of_replicas":"0","number_of_shards":"1"}}
[00:00:01]             │ info [o.e.x.i.IndexLifecycleTransition] [node-01] moving index [.ds-ilm-history-5-2021.08.09-000001] from [{"phase":"new","action":"complete","name":"complete"}] to [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] in policy [ilm-history-ilm-policy]
[00:00:01]             │ info [o.e.c.m.MetadataCreateIndexService] [node-01] [logstash-2015.09.18] creating index, cause [api], templates [], shards [1]/[0]
[00:00:01]             │ info [o.e.c.r.a.AllocationService] [node-01] current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[logstash-2015.09.18][0]]])." previous.health="YELLOW" reason="shards started [[logstash-2015.09.18][0]]"
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Created index "logstash-2015.09.18"
[00:00:01]             │ debg [test/functional/fixtures/es_archiver/makelogs] "logstash-2015.09.18" settings {"index":{"analysis":{"analyzer":{"url":{"max_token_length":"1000","tokenizer":"uax_url_email","type":"standard"}}},"number_of_replicas":"0","number_of_shards":"1"}}
[00:00:01]             │ info [o.e.x.i.IndexLifecycleTransition] [node-01] moving index [.ds-ilm-history-5-2021.08.09-000001] from [{"phase":"hot","action":"unfollow","name":"branch-check-unfollow-prerequisites"}] to [{"phase":"hot","action":"rollover","name":"check-rollover-ready"}] in policy [ilm-history-ilm-policy]
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Indexed 101 docs into "logstash-2015.09.17"
[00:00:01]             │ info [test/functional/fixtures/es_archiver/makelogs] Indexed 301 docs into "logstash-2015.09.18"
[00:00:02]           └-: 
[00:00:02]             └-> "before all" hook in ""
[00:00:25]             └-: creating and deleting default index
[00:00:25]               └-> "before all" hook in "creating and deleting default index"
[00:00:25]               └-> "before all" hook in "creating and deleting default index"
[00:00:25]                 │ debg replacing kibana config doc: {}
[00:00:26]                 │ debg navigating to settings url: http://localhost:61151/app/management
[00:00:26]                 │ debg navigate to: http://localhost:61151/app/management
[00:00:26]                 │ debg browser[INFO] http://localhost:61151/app/management?_t=1628504342187 281 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:00:26]                 │
[00:00:26]                 │ debg browser[INFO] http://localhost:61151/bootstrap.js 41:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:00:26]                 │ debg ... sleep(700) start
[00:00:26]                 │ debg ... sleep(700) end
[00:00:26]                 │ debg returned from get, calling refresh
[00:00:27]                 │ debg browser[INFO] http://localhost:61151/app/management?_t=1628504342187 281 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:00:27]                 │
[00:00:27]                 │ debg browser[INFO] http://localhost:61151/bootstrap.js 41:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:00:28]                 │ debg currentUrl = http://localhost:61151/app/management
[00:00:28]                 │          appUrl = http://localhost:61151/app/management
[00:00:28]                 │ debg TestSubjects.find(kibanaChrome)
[00:00:28]                 │ debg Find.findByCssSelector('[data-test-subj="kibanaChrome"]') with timeout=60000
[00:00:28]                 │ debg ... sleep(501) start
[00:00:28]                 │ debg ... sleep(501) end
[00:00:28]                 │ debg in navigateTo url = http://localhost:61151/app/management
[00:00:28]                 │ debg clickKibanaIndexPatterns link
[00:00:28]                 │ debg TestSubjects.click(indexPatterns)
[00:00:28]                 │ debg Find.clickByCssSelector('[data-test-subj="indexPatterns"]') with timeout=10000
[00:00:28]                 │ debg Find.findByCssSelector('[data-test-subj="indexPatterns"]') with timeout=10000
[00:00:28]                 │ debg isGlobalLoadingIndicatorVisible
[00:00:28]                 │ debg TestSubjects.exists(globalLoadingIndicator)
[00:00:28]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="globalLoadingIndicator"]') with timeout=1500
[00:00:30]                 │ debg --- retry.tryForTime error: [data-test-subj="globalLoadingIndicator"] is not displayed
[00:00:30]                 │ debg TestSubjects.exists(globalLoadingIndicator-hidden)
[00:00:30]                 │ debg Find.existsByCssSelector('[data-test-subj="globalLoadingIndicator-hidden"]') with timeout=100000
[00:00:33]               └-: validation
[00:00:33]                 └-> "before all" hook for "can display errors"
[00:00:33]                 └-> can display errors
[00:00:33]                   └-> "before each" hook: global before each for "can display errors"
[00:00:33]                   │ debg TestSubjects.exists(createIndexPatternButtonFlyout)
[00:00:33]                   │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="createIndexPatternButtonFlyout"]') with timeout=2500
[00:00:36]                   │ debg --- retry.tryForTime error: [data-test-subj="createIndexPatternButtonFlyout"] is not displayed
[00:00:36]                   │ debg TestSubjects.exists(createIndexPatternButton)
[00:00:36]                   │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="createIndexPatternButton"]') with timeout=2500
[00:00:36]                   │ debg TestSubjects.click(createIndexPatternButton)
[00:00:36]                   │ debg Find.clickByCssSelector('[data-test-subj="createIndexPatternButton"]') with timeout=10000
[00:00:36]                   │ debg Find.findByCssSelector('[data-test-subj="createIndexPatternButton"]') with timeout=10000
[00:00:36]                   │ debg TestSubjects.exists(createIndexPatternButtonFlyout)
[00:00:36]                   │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="createIndexPatternButtonFlyout"]') with timeout=2500
[00:00:36]                   │ debg TestSubjects.click(createIndexPatternButtonFlyout)
[00:00:36]                   │ debg Find.clickByCssSelector('[data-test-subj="createIndexPatternButtonFlyout"]') with timeout=10000
[00:00:36]                   │ debg Find.findByCssSelector('[data-test-subj="createIndexPatternButtonFlyout"]') with timeout=10000
[00:00:36]                   │ debg setIndexPatternField(log*)
[00:00:36]                   │ debg TestSubjects.find(createIndexPatternNameInput)
[00:00:36]                   │ debg Find.findByCssSelector('[data-test-subj="createIndexPatternNameInput"]') with timeout=10000
[00:00:37]                   │ debg setIndexPatternField set to log*
[00:00:37]                   │ debg TestSubjects.find(saveIndexPatternButton)
[00:00:37]                   │ debg Find.findByCssSelector('[data-test-subj="saveIndexPatternButton"]') with timeout=10000
[00:00:37]                   │ debg Find.findByClassName('euiFormErrorText') with timeout=10000
[00:00:47]                   │ info Taking screenshot "/dev/shm/workspace/parallel/15/kibana/test/functional/screenshots/failure/management  creating and deleting default index validation can display errors.png"
[00:00:47]                   │ info Current URL is: http://localhost:61151/app/management/kibana/indexPatterns/patterns/3eb85680-f8fb-11eb-84cb-8de80e1ce81f#/?_a=(tab:indexedFields)
[00:00:47]                   │ info Saving page source to: /dev/shm/workspace/parallel/15/kibana/test/functional/failure_debug/html/management  creating and deleting default index validation can display errors.html
[00:00:47]                   └- ✖ fail: management  creating and deleting default index validation can display errors
[00:00:47]                   │      TimeoutError: Waiting for element to be located By(css selector, .euiFormErrorText)
[00:00:47]                   │ Wait timed out after 10031ms
[00:00:47]                   │       at /dev/shm/workspace/parallel/15/kibana/node_modules/selenium-webdriver/lib/webdriver.js:842:17
[00:00:47]                   │       at runMicrotasks (<anonymous>)
[00:00:47]                   │       at processTicksAndRejections (internal/process/task_queues.js:95:5)
[00:00:47]                   │ 
[00:00:47]                   │ 

Stack Trace

TimeoutError: Waiting for element to be located By(css selector, .euiFormErrorText)
Wait timed out after 10031ms
    at /dev/shm/workspace/parallel/15/kibana/node_modules/selenium-webdriver/lib/webdriver.js:842:17
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  remoteStacktrace: ''
}

Metrics [docs]

✅ unchanged

History

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

cc @walterra

@walterra
Copy link
Contributor Author

@sqren this is ready for another look

@walterra walterra added the auto-backport Deprecated: Automatically backport this PR after it's merged label Aug 11, 2021
@walterra walterra merged commit 86c17da into elastic:master Aug 11, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 11, 2021
…lastic#107370)

- Makes sure fields defined in `FIELDS_TO_ADD_AS_CANDIDATE` and prefixed with one of `FIELD_PREFIX_TO_ADD_AS_CANDIDATE` get queried first when retrieving the `correlation` and `ks-test` value.
- Correctly consider the `includeFrozen` parameter.
- The bulk of the PR is a refactor:
  - Moves `query_*` files to `queries` directory
  - Introduces `asyncSearchServiceStateProvider` to manage the state of the async search service in isolation so that we no longer mutate individual vars or plain objects.
  - Introduces `asyncSearchServiceLogProvider` and extends the log to not only store messages but original error messages retrieved from ES too.
  - Refactors some more functions in separate files and adds unit tests.
  - Removes some deprecated code no longer needed.
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 11, 2021
…-png-pdf-report-type

* 'master' of github.com:elastic/kibana: (101 commits)
  [ML] APM Latency Correlations: Field/value candidates prioritization (elastic#107370)
  [Reporting] Add lenience to a test on the order of asserted logs (elastic#108135)
  [Lens] fix do not submit invalid query in filtered metric (elastic#107542)
  skip flaky test (elastic#108043)
  fix newly introduced type error (elastic#107593)
  [Reporting] server side code clean up (elastic#106940)
  [build_ts_refs] improve caches, allow building a subset of projects (elastic#107981)
  [APM] Add new ftr_e2e to kibana CI and remove current e2e tests. (elastic#107593)
  add manage rules link to alerts dropdown (elastic#107950)
  [ML] Enable Index data visualizer document count chart to update time range query (elastic#106438)
  [Security Solutions][Detection Engine] Fixes "undefined" crash for author field by adding a migration for it (elastic#107230)
  [Actions UI] Fixed Jira Api token label. (elastic#107776)
  [Alerting UI] Fixed display permissions for edit/delete buttons when user has read only access. (elastic#107996)
  [Maps] fix code owners (elastic#108106)
  Update EMS landing page url (elastic#108102)
  Do not render page header for loading domains (elastic#108078)
  Update dependency @elastic/charts to v33.2.2 (elastic#107939)
  [APM] Display throughput as tps (instead of tpm) when bucket size < 60 seconds (elastic#107850)
  [Fleet] Fix all category count (elastic#108089)
  [Security Solution][Bug] - Disable alert table RBAC until fields sorted (elastic#108034)
  ...

# Conflicts:
#	x-pack/plugins/reporting/server/export_types/common/generate_png.ts
#	x-pack/plugins/reporting/server/lib/screenshots/index.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.ts
kibanamachine added a commit that referenced this pull request Aug 11, 2021
…107370) (#108152)

- Makes sure fields defined in `FIELDS_TO_ADD_AS_CANDIDATE` and prefixed with one of `FIELD_PREFIX_TO_ADD_AS_CANDIDATE` get queried first when retrieving the `correlation` and `ks-test` value.
- Correctly consider the `includeFrozen` parameter.
- The bulk of the PR is a refactor:
  - Moves `query_*` files to `queries` directory
  - Introduces `asyncSearchServiceStateProvider` to manage the state of the async search service in isolation so that we no longer mutate individual vars or plain objects.
  - Introduces `asyncSearchServiceLogProvider` and extends the log to not only store messages but original error messages retrieved from ES too.
  - Refactors some more functions in separate files and adds unit tests.
  - Removes some deprecated code no longer needed.

Co-authored-by: Walter Rafelsberger <walter@elastic.co>
@walterra walterra mentioned this pull request Aug 24, 2021
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:correlations auto-backport Deprecated: Automatically backport this PR after it's merged :ml release_note:enhancement Team:APM All issues that need APM UI Team support v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants