index-mgmt.asciidoc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. [role="xpack"]
  2. [[index-mgmt]]
  3. == Index management in {kib}
  4. {kib}'s *Index Management* features are an easy, convenient way to manage your
  5. cluster's indices, <<data-streams,data streams>>, and <<index-templates,index
  6. templates>>. Practicing good index management ensures your data is stored
  7. correctly and in the most cost-effective way possible.
  8. [discrete]
  9. [[index-mgmt-wyl]]
  10. === What you'll learn
  11. You'll learn how to:
  12. * View and edit index settings.
  13. * View mappings and statistics for an index.
  14. * Perform index-level operations, such as refreshes.
  15. * View and manage data streams.
  16. * Create index templates to automatically configure new data streams and indices.
  17. [discrete]
  18. [[index-mgm-req-permissions]]
  19. === Required permissions
  20. If you use {es} {security-features}, the following
  21. <<security-privileges,security privileges>> are required:
  22. * The `monitor` cluster privilege to access {kib}'s *Index Management* features.
  23. * The `view_index_metadata` and `manage` index privileges to view a data stream
  24. or index's data.
  25. * The `manage_index_templates` cluster privilege to manage index templates.
  26. To add these privileges in {kib}, go to *Stack Management > Security > Roles*.
  27. [discrete]
  28. [[view-edit-indices]]
  29. === View and edit indices
  30. Open {kib}'s main menu and click *Stack Management > Index Management*.
  31. [role="screenshot"]
  32. image::images/index-mgmt/management_index_labels.png[Index Management UI]
  33. The *Index Management* page contains an overview of your indices.
  34. Badges indicate if an index is a <<ccr-put-follow,follower index>>, a
  35. <<rollup-get-rollup-index-caps,rollup index>>, or <<unfreeze-index-api,frozen>>.
  36. Clicking a badge narrows the list to only indices of that type.
  37. You can also filter indices using the search bar.
  38. You can drill down into each index to investigate the index
  39. <<index-modules-settings,settings>>, <<mapping,mapping>>, and statistics.
  40. From this view, you can also edit the index settings.
  41. [role="screenshot"]
  42. image::images/index-mgmt/management_index_details.png[Index Management UI]
  43. [float]
  44. === Perform index-level operations
  45. Use the *Manage* menu to perform index-level operations. This menu
  46. is available in the index details view, or when you select the checkbox of one or more
  47. indices on the overview page. The menu includes the following actions:
  48. * <<indices-close,*Close index*>>
  49. * <<indices-forcemerge,*Force merge index*>>
  50. * <<indices-refresh,*Refresh index*>>
  51. * <<indices-flush,*Flush index*>>
  52. * <<indices-delete-index,*Delete index*>>
  53. * *Add* <<set-up-lifecycle-policy,*lifecycle policy*>>
  54. [float]
  55. [[manage-data-streams]]
  56. === Manage data streams
  57. The *Data Streams* view lists your data streams and lets you examine or delete
  58. them.
  59. To view more information about a data stream, such as its generation or its
  60. current index lifecycle policy, click the stream's name.
  61. [role="screenshot"]
  62. image::images/index-mgmt/management_index_data_stream_stats.png[Data stream details]
  63. To view information about the stream's backing indices, click the number in the
  64. *Indices* column.
  65. [role="screenshot"]
  66. image::images/index-mgmt/management_index_data_stream_backing_index.png[Backing index]
  67. [float]
  68. [[manage-index-templates]]
  69. === Manage index templates
  70. The *Index Templates* view lists your templates and lets you examine,
  71. edit, clone, and delete them. Changes made to an index template do not
  72. affect existing indices.
  73. [role="screenshot"]
  74. image::images/index-mgmt/management-index-templates.png[Index templates]
  75. If you don't have any templates, you can create one using the *Create template*
  76. wizard.
  77. [float]
  78. ==== Try it: Create an index template
  79. In this tutorial, you’ll create an index template and use it to configure two
  80. new indices.
  81. *Step 1. Add a name and index pattern*
  82. . In the *Index Templates* view, open the *Create template* wizard.
  83. +
  84. [role="screenshot"]
  85. image::images/index-mgmt/management_index_create_wizard.png[Create wizard]
  86. . In the *Name* field, enter `my-index-template`.
  87. . Set *Index pattern* to `my-index-*` so the template matches any index
  88. with that index pattern.
  89. . Leave *Data Stream*, *Priority*, *Version*, and *_meta field* blank or as-is.
  90. *Step 2. Add settings, mappings, and aliases*
  91. . Add <<indices-component-template,component templates>> to your index template.
  92. +
  93. Component templates are pre-configured sets of mappings, index settings, and
  94. aliases you can reuse across multiple index templates. Badges indicate
  95. whether a component template contains mappings (*M*), index settings (*S*),
  96. aliases (*A*), or a combination of the three.
  97. +
  98. Component templates are optional. For this tutorial, do not add any component
  99. templates.
  100. +
  101. [role="screenshot"]
  102. image::images/index-mgmt/management_index_component_template.png[Component templates page]
  103. . Define index settings. These are optional. For this tutorial, leave this
  104. section blank.
  105. . Define a mapping that contains an <<object,object>> field named `geo` with a
  106. child <<geo-point,`geo_point`>> field named `coordinates`:
  107. +
  108. [role="screenshot"]
  109. image::images/index-mgmt/management-index-templates-mappings.png[Mapped fields page]
  110. +
  111. Alternatively, you can click the *Load JSON* link and define the mapping as JSON:
  112. +
  113. [source,js]
  114. ----
  115. {
  116. "properties": {
  117. "geo": {
  118. "properties": {
  119. "coordinates": {
  120. "type": "geo_point"
  121. }
  122. }
  123. }
  124. }
  125. }
  126. ----
  127. // NOTCONSOLE
  128. +
  129. You can create additional mapping configurations in the *Dynamic templates* and
  130. *Advanced options* tabs. For this tutorial, do not create any additional
  131. mappings.
  132. . Define an alias named `my-index`:
  133. +
  134. [source,js]
  135. ----
  136. {
  137. "my-index": {}
  138. }
  139. ----
  140. // NOTCONSOLE
  141. . On the review page, check the summary. If everything looks right, click
  142. *Create template*.
  143. *Step 3. Create new indices*
  144. You’re now ready to create new indices using your index template.
  145. . Index the following documents to create two indices:
  146. `my-index-000001` and `my-index-000002`.
  147. +
  148. [source,console]
  149. ----
  150. POST /my-index-000001/_doc
  151. {
  152. "@timestamp": "2019-05-18T15:57:27.541Z",
  153. "ip": "225.44.217.191",
  154. "extension": "jpg",
  155. "response": "200",
  156. "geo": {
  157. "coordinates": {
  158. "lat": 38.53146222,
  159. "lon": -121.7864906
  160. }
  161. },
  162. "url": "https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/charles-fullerton.jpg"
  163. }
  164. POST /my-index-000002/_doc
  165. {
  166. "@timestamp": "2019-05-20T03:44:20.844Z",
  167. "ip": "198.247.165.49",
  168. "extension": "php",
  169. "response": "200",
  170. "geo": {
  171. "coordinates": {
  172. "lat": 37.13189556,
  173. "lon": -76.4929875
  174. }
  175. },
  176. "memory": 241720,
  177. "url": "https://theacademyofperformingartsandscience.org/people/type:astronauts/name:laurel-b-clark/profile"
  178. }
  179. ----
  180. . Use the <<indices-get-index,get index API>> to view the configurations for the
  181. new indices. The indices were configured using the index template you created
  182. earlier.
  183. +
  184. [source,console]
  185. --------------------------------------------------
  186. GET /my-index-000001,my-index-000002
  187. --------------------------------------------------
  188. // TEST[continued]