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

Reduce the amount of has_privileges call #161229

Open
philippkahr opened this issue Jul 5, 2023 · 7 comments
Open

Reduce the amount of has_privileges call #161229

philippkahr opened this issue Jul 5, 2023 · 7 comments
Labels
enhancement New value added to drive a business result Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! unified-security-painpoint Highlights issues that are painpoints as a result of the lack of a unified security model

Comments

@philippkahr
Copy link
Contributor

philippkahr commented Jul 5, 2023

Version: 8.8.1, everything on Elastic Cloud.

When performing a simple ES Query type alert rule that just checks if the amount of docs is above a threshold, like this:
Screenshot 2023-07-05 at 08 53 24

The Kibana APM and Elasticsearch instrumentation then shows that a lot of time is spent on the has_privileges checks.
image from a transaction point of view.

Looking at the spans:
image

Here is what the entire trace looks like
overview elastic-cloud com_app_apm_services_kibana_transactions_view_kuery=labels deploymentId_%20%2212a0e5b525c14e57b156463ee7c8af67%22 rangeFrom=now-15m rangeTo=now environment=ENVIRONMENT_ALL serviceGroup= comparisonEnabled=true tran (2)

@botelastic botelastic bot added the needs-team Issues missing a team label label Jul 5, 2023
@dmlemeshko dmlemeshko added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Jul 5, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Jul 5, 2023
@azasypkin
Copy link
Member

Based on the very long and intricate APM trace, it appears that unwinding the issue won't be a straightforward task and will likely require collaboration between @elastic/response-ops, @elastic/kibana-security, and @elastic/kibana-core. We might also require assistance from the @elastic/apm-ui to access and interpret these traces (unfortunately, I couldn't even load them in our o11y cluster and had to give up after waiting for around 15 minutes for the timeline to show up).

Since the initial request originates from the Alerting UI and there are several requests to the .kibana_alerting_cases_* index in the trace, I'd ask @elastic/response-ops to assist with the initial investigation to determine if there are any optimizations that can be made at their level. If such optimizations are not feasible or not enough, then we need to identify the specific issues with the Security APIs and other functionalities that are causing the problem.

@dgieselaar
Copy link
Member

@azasypkin happy to help out, feel free to put something on my calendar

@philippkahr
Copy link
Contributor Author

I am not an expert in this topic and I definitely do not want to lead any of you to wrong conclusions. When looking through the APM, I see 5x a GET */_doc/strava%3Aconfig%3A8.8.1. To me, as a non kibana dev, it looks like every of this config pulls is "wrapped" in an has_privileges call. Could we automatically reduce the has_privileges call, when we reduce the amount of config pulls? Maybe even merge the config + rule setting call?

I am not entirely sure if this should be part of this investigation, so I opened a second issue #161382 close it if no needed :)

image

@rudolf
Copy link
Contributor

rudolf commented Jul 12, 2024

This is very similar to #82218 To address that issue we added a 5s UiSettings cache to each request.

I suspect since these are server-side calls we don't use a UiClient from the request context but instead create one with UiSettingsServiceStart.asScopedToClient. In that case we won't benefit from the cache.

@legrego legrego added the unified-security-painpoint Highlights issues that are painpoints as a result of the lack of a unified security model label Jul 17, 2024
@mikecote
Copy link
Contributor

Optimizations have been made in the Kibana Alerting and Task Manager framework to not call the has_privileges API as frequent. A downstream issue still exists whenever using search source / data view services (#192170) and some calls are still made by rule types (ex: security detection rules). Calls to such endpoint should be drastically reduced now. Perhaps sufficient to close this GitHub issue?

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 Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! unified-security-painpoint Highlights issues that are painpoints as a result of the lack of a unified security model
Projects
No open projects
Development

No branches or pull requests

9 participants