Create or update role API

[experimental] This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. Create a new Kibana role, or update the attributes of an existing role. Kibana roles are stored in the Elasticsearch native realm.

Request

PUT <kibana host>:<port>/api/security/role/my_kibana_role

Prerequisite

To use the create or update role API, you must have the manage_security cluster privilege.

Request body

metadata

(Optional, object) In the metadata object, keys that begin with _ are reserved for system usage.

elasticsearch

(Optional, object) Elasticsearch cluster and index privileges. Valid keys include cluster, indices, and run_as. For more information, see Defining roles.

kibana

(list) Objects that specify the Kibana privileges for the role.

Properties of kibana

  • base

    (Optional, list) A base privilege. When specified, the base must be ["all"] or ["read"]. When the base privilege is specified, you are unable to use the feature section. “all” grants read/write access to all Kibana features for the specified spaces. “read” grants read-only access to all Kibana features for the specified spaces.

    feature

    (object) Contains privileges for specific features. When the feature privileges are specified, you are unable to use the base section. To retrieve a list of available features, use the features API.

    spaces

    (list) The spaces to apply the privileges to. To grant access to all spaces, set to ["*"], or omit the value.

Response code

204

Indicates a successful call.

Examples

Grant access to various features in all spaces:

  1. $ curl -X PUT api/security/role/my_kibana_role
  2. {
  3. "metadata" : {
  4. "version" : 1
  5. },
  6. "elasticsearch": {
  7. "cluster" : [ ],
  8. "indices" : [ ]
  9. },
  10. "kibana": [
  11. {
  12. "base": [],
  13. "feature": {
  14. "discover": [
  15. "all"
  16. ],
  17. "visualize": [
  18. "all"
  19. ],
  20. "dashboard": [
  21. "all"
  22. ],
  23. "dev_tools": [
  24. "read"
  25. ],
  26. "advancedSettings": [
  27. "read"
  28. ],
  29. "indexPatterns": [
  30. "read"
  31. ],
  32. "timelion": [
  33. "all"
  34. ],
  35. "graph": [
  36. "all"
  37. ],
  38. "apm": [
  39. "read"
  40. ],
  41. "maps": [
  42. "read"
  43. ],
  44. "canvas": [
  45. "read"
  46. ],
  47. "infrastructure": [
  48. "all"
  49. ],
  50. "logs": [
  51. "all"
  52. ],
  53. "uptime": [
  54. "all"
  55. ]
  56. },
  57. "spaces": [
  58. "*"
  59. ]
  60. }
  61. ]
  62. }

Grant dashboard-only access to only the Marketing space:

  1. $ curl -X PUT api/security/role/my_kibana_role
  2. {
  3. "metadata" : {
  4. "version" : 1
  5. },
  6. "elasticsearch": {
  7. "cluster" : [ ],
  8. "indices" : [ ]
  9. },
  10. "kibana": [
  11. {
  12. "base": [],
  13. "feature": {
  14. "dashboard": ["read"]
  15. },
  16. "spaces": [
  17. "marketing"
  18. ]
  19. }
  20. ]
  21. }

Grant full access to all features in the Default space:

  1. $ curl -X PUT api/security/role/my_kibana_role
  2. {
  3. "metadata" : {
  4. "version" : 1
  5. },
  6. "elasticsearch": {
  7. "cluster" : [ ],
  8. "indices" : [ ]
  9. },
  10. "kibana": [
  11. {
  12. "base": ["all"],
  13. "feature": {
  14. },
  15. "spaces": [
  16. "default"
  17. ]
  18. }
  19. ]
  20. }

Grant different access to different spaces:

  1. $ curl -X PUT api/security/role/my_kibana_role
  2. {
  3. "metadata" : {
  4. "version" : 1
  5. },
  6. "elasticsearch": {
  7. "cluster" : [ ],
  8. "indices" : [ ]
  9. },
  10. "kibana": [
  11. {
  12. "base": [],
  13. "feature": {
  14. "discover": ["all"],
  15. "dashboard": ["all"]
  16. },
  17. "spaces": [
  18. "default"
  19. ]
  20. },
  21. {
  22. "base": ["read"],
  23. "spaces": [
  24. "marketing",
  25. "sales"
  26. ]
  27. }
  28. ]
  29. }

Grant access to Kibana and Elasticsearch:

  1. $ curl -X PUT api/security/role/my_kibana_role
  2. {
  3. "metadata" : {
  4. "version" : 1
  5. },
  6. "elasticsearch": {
  7. "cluster" : [ "all" ],
  8. "indices" : [ {
  9. "names" : [ "index1", "index2" ],
  10. "privileges" : [ "all" ],
  11. "field_security" : {
  12. "grant" : [ "title", "body" ]
  13. },
  14. "query" : "{\"match\": {\"title\": \"foo\"}}"
  15. } ]
  16. },
  17. "kibana": [
  18. {
  19. "base": ["all"],
  20. "feature": {
  21. },
  22. "spaces": [
  23. "default"
  24. ]
  25. }
  26. ]
  27. }

Most Popular