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] Add context information to search slow log entries #147378

Closed
5 tasks done
jgowdyelastic opened this issue Dec 12, 2022 · 6 comments
Closed
5 tasks done

[ML] Add context information to search slow log entries #147378

jgowdyelastic opened this issue Dec 12, 2022 · 6 comments
Assignees
Labels
enhancement New value added to drive a business result Meta :ml v8.8.0

Comments

@jgowdyelastic
Copy link
Member

jgowdyelastic commented Dec 12, 2022

We should be able to add context information to all searches so they appear in the search slow log. This applies to all the plugins the ML team maintains.

v8.7

v8.8

@jgowdyelastic jgowdyelastic added enhancement New value added to drive a business result :ml v8.7.0 labels Dec 12, 2022
@jgowdyelastic jgowdyelastic self-assigned this Dec 12, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@peteharverson peteharverson changed the title [ML] Add ML context information to search slow log entries [ML] Add context information to search slow log entries Jan 17, 2023
jgowdyelastic added a commit that referenced this issue Jan 24, 2023
Adds the page path as the ID to our existing execution context and adds
an additional context entry to every ml kibana endpoint.
In the search slow log, the id for each slow search from ML will look
like this:


`"a90d5297-fd77-4ea0-ac0d-c302963d7e75;kibana:application:ml:%2Fjobs%2Fnew_job%2Fsingle_metric;application:ml:%2Fapi%2Fml%2Fjobs%2Fnew_job_line_chart`

Separating by semicolon:
`a90d5297-fd77-4ea0-ac0d-c302963d7e75` -> kibana ID

`kibana:application:ml:%2Fjobs%2Fnew_job%2Fsingle_metric` -> default
context items added on the client side to show the source page.

`application:ml:%2Fapi%2Fml%2Fjobs%2Fnew_job_line_chart` -> new items
added by the server to show the source endpoint path.

Note, the paths have been encoded to replace the forward slashes.

Part of #147378
@sophiec20
Copy link
Contributor

Does this show user id as well as component and plugin?
Are we targeting this for 8.7?

@peteharverson
Copy link
Contributor

@sophiec20 in answer to your questions:

Does this show user id as well as component and plugin?

The information added in #148746 does not include user ID. We will need to investigate if this is possible. We aren't aware of any other plugins which currently add the user.

Are we targeting this for 8.7?

The changes for the ml plugin are in for 8.7, but transforms, aiops and data_visualizer will follow in a later release.

@sophiec20
Copy link
Contributor

The information added in #148746 does not include user ID. We will need to investigate if this is possible. We aren't aware of any other plugins which currently add the user.

I wasn't saying it "must", at this stage it is just a question. Would still be useful to investigate what is possible.

@jgowdyelastic
Copy link
Member Author

jgowdyelastic commented Feb 9, 2023

I think the decision on whether we add user ID to the slow log would need to be made by someone in the elasticsearch, security or core kibana teams. We could be exposing sensitive information.
Also, I don't think it should be added to the part of the log which we are able to customise (the "elasticsearch.slowlog.id" property) as this is only being used to identify the location in app or endpoint which has triggered the search.

User ID could be added as a separate property in the log, but this is not something we could do.

example log document:

{
  "@timestamp": "2023-01-13T10:10:21.985Z",
  "log.level": "TRACE",
  "elasticsearch.slowlog.id": "a90d5297-fd77-4ea0-ac0d-c302963d7e75;kibana:application:ml:%2Fjobs%2Fnew_job%2Fsingle_metric;application:ml:%2Fapi%2Fml%2Fjobs%2Fnew_job_line_chart",
  "elasticsearch.slowlog.message": "[gtfsbeat-8.0.0-2019][0]",
  "elasticsearch.slowlog.search_type": "QUERY_THEN_FETCH",
  "elasticsearch.slowlog.source": "{\\\"size\\\":0,\\\"query\\\":{\\\"bool\\\":{\\\"must\\\":[{\\\"match_all\\\":{\\\"boost\\\":1.0}},{\\\"range\\\":{\\\"@timestamp\\\":{\\\"boost\\\":1.0}}}],\\\"boost\\\":1.0}},\\\"track_total_hits\\\":2147483647,\\\"aggregations\\\":{\\\"times\\\":{\\\"date_histogram\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"fixed_interval\\\":\\\"7200000ms\\\",\\\"offset\\\":0,\\\"order\\\":{\\\"_key\\\":\\\"asc\\\"},\\\"keyed\\\":false,\\\"min_doc_count\\\":0,\\\"extended_bounds\\\":{\\\"min\\\":1556141284000,\\\"max\\\":1560430139000}}}}}",
  "elasticsearch.slowlog.stats": "[]",
  "elasticsearch.slowlog.took": "132.3ms",
  "elasticsearch.slowlog.took_millis": 132,
  "elasticsearch.slowlog.total_hits": "2882527 hits",
  "elasticsearch.slowlog.total_shards": 1,
  "ecs.version": "1.2.0",
  "service.name": "ES_ECS",
  "event.dataset": "elasticsearch.index_search_slowlog",
  "process.thread.name": "elasticsearch[node-0][search][T#10]",
  "log.logger": "index.search.slowlog.query",
  "trace.id": "efcb4fa736fa31bd8a36695e83b7507b",
  "elasticsearch.cluster.uuid": "XPf0bmrNSRy74IXugIAcUg",
  "elasticsearch.node.id": "ymkG7GGFR9WAhCP7xmsfHQ",
  "elasticsearch.node.name": "node-0",
  "elasticsearch.cluster.name": "default-8.7.0-2427"
}

walterra added a commit that referenced this issue Mar 31, 2023
Part of #147378

- Similar to #148746, adds execution context to transform API endpoints.
- Moves `createExecutionContext` to package `@kbn/ml-route-utils`.
walterra added a commit that referenced this issue Apr 19, 2023
…sts (#154891)

Part of #147378. This PR adds
context information to data.search requests so that they appear in the
search slow log.
saarikabhasi pushed a commit to saarikabhasi/kibana that referenced this issue Apr 19, 2023
…sts (elastic#154891)

Part of elastic#147378. This PR adds
context information to data.search requests so that they appear in the
search slow log.
@peteharverson
Copy link
Contributor

Closing issue as all the planned work has been completed for 8.8.

nikitaindik pushed a commit to nikitaindik/kibana that referenced this issue Apr 25, 2023
…sts (elastic#154891)

Part of elastic#147378. This PR adds
context information to data.search requests so that they appear in the
search slow log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Meta :ml v8.8.0
Projects
None yet
Development

No branches or pull requests

6 participants