index-mgmt.asciidoc 6.8 KB

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