Skip to content

[ResponseOps] Update kibana system user with esql view permissions.#143568

Merged
adcoelho merged 3 commits intoelastic:mainfrom
adcoelho:alerting-v2-esql-views-permissions
Mar 6, 2026
Merged

[ResponseOps] Update kibana system user with esql view permissions.#143568
adcoelho merged 3 commits intoelastic:mainfrom
adcoelho:alerting-v2-esql-views-permissions

Conversation

@adcoelho
Copy link
Copy Markdown
Contributor

@adcoelho adcoelho commented Mar 4, 2026

Summary

We want to allow the Kibana system user to be able to manage ESQL views.

Draft PR for the Kibana implementation.

The permissions create_view, manage_view, and manage are the ones required in the error output when using the esClient to create a new view on startup.

I also updated the tests to include the ESQLViewActionNames, I hope that is correct.

@adcoelho adcoelho self-assigned this Mar 4, 2026
@adcoelho adcoelho requested a review from a team as a code owner March 4, 2026 11:16
@adcoelho adcoelho added >non-issue :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v9.4.0 labels Mar 4, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTING_V2_INDEX_ALIAS).privileges("all").build(),
RoleDescriptor.IndicesPrivileges.builder()
.indices(ReservedRolesStore.ALERTING_V2_INDEX_ALIAS)
.privileges("create_view", "manage_view", "manage", "all")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you only need to grant create_view here and that the error message indicates any of create_view, manage_view, or manage will grant the indices:admin/esql/view/put action.

https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java#L78

That test indicates that all should also grant the necessary action, which was already granted. So I'm wondering if this will actually fix your issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

all already grants any view (and index) actions. If you're running into issues let me know and I can try to help out.

all is indices:*, manage is indices:admin/*, manage_view is indices:admin/esql/view* and the PUT, GET and DELETE operations are indices:admin/esql/view/put|get|delete.

@rgodfrey-elastic
Copy link
Copy Markdown
Contributor

Is this PR attempting to solve the same problem as #143455 ? The titles are almost the same but are modifying different indices

Copy link
Copy Markdown
Contributor

@jfreden jfreden left a comment

Choose a reason for hiding this comment

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

all should already cover this. Let me know if you're running into issues and I can try to help out over slack or zoom. Thanks!

RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTING_V2_INDEX_ALIAS).privileges("all").build(),
RoleDescriptor.IndicesPrivileges.builder()
.indices(ReservedRolesStore.ALERTING_V2_INDEX_ALIAS)
.privileges("create_view", "manage_view", "manage", "all")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

all already grants any view (and index) actions. If you're running into issues let me know and I can try to help out.

all is indices:*, manage is indices:admin/*, manage_view is indices:admin/esql/view* and the PUT, GET and DELETE operations are indices:admin/esql/view/put|get|delete.

@adcoelho adcoelho force-pushed the alerting-v2-esql-views-permissions branch from 5aa417d to f34062c Compare March 5, 2026 09:35
@adcoelho adcoelho requested a review from a team as a code owner March 5, 2026 09:35
@adcoelho
Copy link
Copy Markdown
Contributor Author

adcoelho commented Mar 5, 2026

After a chat with @jfreden, I understood the original call to the API was failing because the role did not have all privileges for the view name. I thought they were only necessary for the source index, so .alerting-foobar -> alerting-foobar was failing.

In addition to that, after our chat, I decided to go for the $. prefix convention for the view name.

I changed the PR to target $.alerting*.

// "Alerting V2" indexes
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTING_V2_INDEX_ALIAS).privileges("all").build(),
// "Alerting V2" views prefix
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTING_V2_VIEWS).privileges("all").build(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you need all here? Since this is only managing views you should at most need manage_view (all CRUD). What are the operations you're planning on doing? If it's only adding views, I'd stick to create_view otherwise manage_view.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When you mentioned above that:

all already grants any view (and index) actions.

I assumed that was the required privilege for the view name, too.

I realize now that it is still a superset of what we actually need. I will change to create_view.

Copy link
Copy Markdown
Contributor

@jfreden jfreden left a comment

Choose a reason for hiding this comment

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

LGTM!

@adcoelho adcoelho merged commit 3251506 into elastic:main Mar 6, 2026
41 checks passed
adcoelho added a commit to elastic/kibana that referenced this pull request Mar 6, 2026
## Summary

**The focus of this PR is the view creation logic. I will create a
follow-up PR with an `$.alerting-episodes` view when we decide which
fields we want on the alerts table.**

This PR adds startup initialization of ES|QL views in the Alerting v2
plugin(in addition to the existing data stream resource setup). Views
are created in Elasticsearch via the `/_query/view` API, so alerting can
use them.

[There is currently a separate PR in the Elasticsearch
repo](elastic/elasticsearch#143568) that updates
the Kibana system user permissions to allow for the ESQL view
management.

The views created by this PR are:
```
$.alerting-events -> FROM .alerting-events
$.alerting-actions -> FROM .alerting-actions
```
spinscale pushed a commit to spinscale/elasticsearch that referenced this pull request Mar 6, 2026
…lastic#143568)

* Adds alerting v2 views permissions.

* Change alerting v2 view privileges to create_view only.

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
sidosera pushed a commit to sidosera/elasticsearch that referenced this pull request Mar 6, 2026
…lastic#143568)

* Adds alerting v2 views permissions.

* Change alerting v2 view privileges to create_view only.

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
jfreden added a commit to jfreden/elasticsearch that referenced this pull request Mar 9, 2026
jfreden added a commit that referenced this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants