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

[Search service] Add search IDs to requests made to Elasticsearch #16493

Closed
jpcarey opened this issue Feb 2, 2018 · 9 comments
Closed

[Search service] Add search IDs to requests made to Elasticsearch #16493

jpcarey opened this issue Feb 2, 2018 · 9 comments
Assignees
Labels
enhancement New value added to drive a business result Feature:Search Querying infrastructure in Kibana impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort

Comments

@jpcarey
Copy link

jpcarey commented Feb 2, 2018

Describe the feature: Elasticsearch now supports providing a search id by setting X-Opaque-Id http header. Having a search ID set could be useful in tracking down the source of problematic queries (if this could be logged at both kibana & elasticsearch)

elastic/elasticsearch#27764

Extra terms for seach-ability:

  • Mapping query to saved object source via id
@jbudz jbudz added the Team:Operations Team label for Operations Team label Feb 8, 2018
@stacey-gammon stacey-gammon added triage_needed enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Mar 1, 2018
@danopia
Copy link

danopia commented Apr 2, 2018

I have a reverse proxy in front of Kibana which knows user identities and is capable of attaching X-Opaque-Id to Kibana's /elasticsearch/ requests to identify where the search request came from. Unfortunately, Kibana didn't seem to carry them through to the backend, and in research I ended up on this issue.

If anyone else is in the same boat—making your own opaque IDs in front of Kibana—dropping this into kibana.yml lets it pass through 😄 (env-var didn't seem to work)

elasticsearch.requestHeadersWhitelist: [ x-opaque-id ]

@sergii-sakharov
Copy link

sergii-sakharov commented Jun 5, 2018

Worked this issue around by introducing "dummy filters" with object ids embedded in them for each Kibana object.
The reverse proxy between Kibana and Elasticsearch is logging all of the _msearch requests and thus allows for precise tracking. As a bonus we're ingesting those logs with a pipeline that parses epoch timestamps and object ids out so that its possible to have a dashboard/search that monitors

  1. how long requests took
  2. all object ids involved
  3. who done it
  4. what time range and time offset was used
  5. what was the actual query sent to ES

Can probably setup a watcher on top of all of this to send out best practices to potential culprits )

The worst thing in all of this are those "dummy filters" as they have to be re-generated and re-uploaded into Kibana regularly with a script

Here's an example of the generated filter for a visualization
{ "query": { "bool": { "must_not": [ { "term": {
"_index": "visualizationId:MessageBus_ActiveMessageCount"
} } ] } } }

With a custom label: metadata (don't remove)

@timroes timroes added Feature:Search Querying infrastructure in Kibana Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed :Discovery labels Sep 16, 2018
@timroes timroes added :AppArch and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Mar 27, 2019
@lanerjo
Copy link

lanerjo commented Apr 4, 2019

+1
This IMO should be a high priority. Kibana should be able to generate a unique ID per request so that it is possible to trace down problematic queries through logs much easier.

This should be implemented as part of the service as a feature, we shouldn't have to depend on a third party application or some "hack" to implement a feature such as this.

@stacey-gammon
Copy link
Contributor

What information should be associated with that search id?

Some things to keep in mind:

  • A query might not originate from something with a saved object id. For instance, a user does "create new visualize -> creates an expensive query".
  • A query might not be reproducible with a URL. For instance, a user starts to type into the filter bar something that causes KQL to make a very expensive call to get the unique field values for auto-complete. Refreshing the page however will cause you to lose that filter because it hasn't yet been applied. This could also be the case with different permissions - one user hits more indices than another user for the same URL.

Maybe it would help if we included a lot of information, such as:

  • An optional associated saved object id
  • The url
  • An optional description a developer could pass with a query, like "KQL: auto complete"
  • Plugin id?

@lukasolson lukasolson changed the title add search ids to requests made to elasticsearch [Search service] Add search IDs to requests made to Elasticsearch Jan 16, 2020
@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort labels Jun 2, 2021
@mshustov
Copy link
Contributor

@stacey-gammon I started working on #101587 Could you elaborate on a few moments:

An optional associated saved object id

Not all Kibana entities have SO, as you said. Maybe we should pass Kibana entity identifier? With this id we should be able to find an associated SO.

The url

Do you mean the URL to a current Kibana entity (a visualization, for example)? the url to a SO? the current page URL?

@stacey-gammon
Copy link
Contributor

Not all Kibana entities have SO, as you said. Maybe we should pass Kibana entity identifier? With this id we should be able to find an associated SO.

What is the Kibana Entity Identifier? You mean the type, like "Lens"?

Do you mean the URL to a current Kibana entity (a visualization, for example)? the url to a SO? the current page URL?

I meant the current page URL. For example, if an expensive query is coming from the security network page - there is no saved object.

@mshustov
Copy link
Contributor

What is the Kibana Entity Identifier? You mean the type, like "Lens"?

yes, a dashboard panel, canvas workpad, etc.

if an expensive query is coming from the security network page - there is no saved object.

Let's consider a dashboard page with several panels. It's hard to identify what panel causes a specific query. So, I'd say we are interested in panel URL that a user can open to the browser and modify the panel.

@stacey-gammon
Copy link
Contributor

Let's consider a dashboard page with several panels. It's hard to identify what panel causes a specific query. So, I'd say we are interested in panel URL that a user can open to the browser and modify the panel.

Yea, that's a good example. That might be tough though because the dashboard doesn't send the query, the embeddable does. The embeddable knows it's in a dashboard, but doesn't know where that dashboard is embedded.

@lukasolson
Copy link
Member

Closing in favor of #97934.

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 Feature:Search Querying infrastructure in Kibana impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:small Small Level of Effort
Projects
None yet
Development

No branches or pull requests