index-mgmt.asciidoc 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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>>, <<index-templates,index
  6. templates>>, and <<ingest-enriching-data,enrich policies>>. Practicing good index management ensures your data is stored
  7. correctly and in the most cost-effective way possible.
  8. To use these features, go to *Stack Management* > *Index Management*.
  9. [discrete]
  10. [[index-mgmt-wyl]]
  11. [discrete]
  12. [[index-mgm-req-permissions]]
  13. === Required permissions
  14. If you use {es} {security-features}, the following
  15. <<security-privileges,security privileges>> are required:
  16. * The `monitor` cluster privilege to access {kib}'s *Index Management* features.
  17. * The `view_index_metadata` and `manage` index privileges to view a data stream
  18. or index's data.
  19. * The `manage_index_templates` cluster privilege to manage index templates.
  20. To add these privileges, go to *Stack Management > Security > Roles* or use the <<security-api-put-role,Create or update roles API>>.
  21. [discrete]
  22. [[view-edit-indices]]
  23. === Manage indices
  24. Investigate your indices and perform operations from the *Indices* view.
  25. [role="screenshot"]
  26. image::images/index-mgmt/management_index_labels.png[Index Management UI]
  27. * To show details and perform operations such as close, forcemerge, and flush,
  28. click the index name. To perform operations
  29. on multiple indices, select their checkboxes and then open the *Manage* menu.
  30. For more information on managing indices, refer to <<indices, Index APIs>>.
  31. * To filter the list of indices, use the search bar or click a badge.
  32. Badges indicate if an index is a <<ccr-put-follow,follower index>>, a
  33. <<rollup-get-rollup-index-caps,rollup index>>, or <<unfreeze-index-api,frozen>>.
  34. * To drill down into the index
  35. <<mapping,mappings>>, <<index-modules-settings,settings>>, and statistics,
  36. click an index name. From this view, you can navigate to *Discover* to
  37. further explore the documents in the index.
  38. +
  39. [role="screenshot"]
  40. image::images/index-mgmt/management_index_details.png[Index Management UI]
  41. [float]
  42. [[manage-data-streams]]
  43. === Manage data streams
  44. Investigate your data streams and address lifecycle management needs in the *Data Streams* view.
  45. The value in the *Indices* column indicates the number of backing indices. Click this number to drill down into details.
  46. A value in the data retention column indicates that the data stream is managed by a <<data-stream-lifecycle,data stream lifecycle policy>>.
  47. This value is the time period for which your data is guaranteed to be stored. Data older than this period can be deleted by
  48. Elasticsearch at a later time.
  49. [role="screenshot"]
  50. image::images/index-mgmt/management-data-stream-fields.png[Data stream details]
  51. * To view more information about a data stream, such as its generation or its
  52. current index lifecycle policy, click the stream's name. From this view, you can navigate to *Discover* to
  53. further explore data within the data stream.
  54. * preview:[]To edit the data retention value, open the *Manage* menu, and then click *Edit data retention*.
  55. This action is only available if your data stream is not managed by an ILM policy.
  56. [float]
  57. [[manage-index-templates]]
  58. === Manage index templates
  59. Create,
  60. edit, clone, and delete your index templates in the *Index Templates* view. Changes made to an index template do not
  61. affect existing indices.
  62. [role="screenshot"]
  63. image::images/index-mgmt/management-index-templates.png[Index templates]
  64. [float]
  65. ==== Try it: Create an index template
  66. In this tutorial, you’ll create an index template and use it to configure two
  67. new indices.
  68. *Step 1. Add a name and index pattern*
  69. . In the *Index Templates* view, open the *Create template* wizard.
  70. +
  71. [role="screenshot"]
  72. image::images/index-mgmt/management_index_create_wizard.png[Create wizard]
  73. . In the *Name* field, enter `my-index-template`.
  74. . Set *Index pattern* to `my-index-*` so the template matches any index
  75. with that index pattern.
  76. . Leave *Data Stream*, *Priority*, *Version*, and *_meta field* blank or as-is.
  77. *Step 2. Add settings, mappings, and aliases*
  78. . Add <<indices-component-template,component templates>> to your index template.
  79. +
  80. Component templates are pre-configured sets of mappings, index settings, and
  81. aliases you can reuse across multiple index templates. Badges indicate
  82. whether a component template contains mappings (*M*), index settings (*S*),
  83. aliases (*A*), or a combination of the three.
  84. +
  85. Component templates are optional. For this tutorial, do not add any component
  86. templates.
  87. +
  88. [role="screenshot"]
  89. image::images/index-mgmt/management_index_component_template.png[Component templates page]
  90. . Define index settings. These are optional. For this tutorial, leave this
  91. section blank.
  92. . Define a mapping that contains an <<object,object>> field named `geo` with a
  93. child <<geo-point,`geo_point`>> field named `coordinates`:
  94. +
  95. [role="screenshot"]
  96. image::images/index-mgmt/management-index-templates-mappings.png[Mapped fields page]
  97. +
  98. Alternatively, you can click the *Load JSON* link and define the mapping as JSON:
  99. +
  100. [source,js]
  101. ----
  102. {
  103. "properties": {
  104. "geo": {
  105. "properties": {
  106. "coordinates": {
  107. "type": "geo_point"
  108. }
  109. }
  110. }
  111. }
  112. }
  113. ----
  114. // NOTCONSOLE
  115. +
  116. You can create additional mapping configurations in the *Dynamic templates* and
  117. *Advanced options* tabs. For this tutorial, do not create any additional
  118. mappings.
  119. . Define an alias named `my-index`:
  120. +
  121. [source,js]
  122. ----
  123. {
  124. "my-index": {}
  125. }
  126. ----
  127. // NOTCONSOLE
  128. . On the review page, check the summary. If everything looks right, click
  129. *Create template*.
  130. *Step 3. Create new indices*
  131. You’re now ready to create new indices using your index template.
  132. . Index the following documents to create two indices:
  133. `my-index-000001` and `my-index-000002`.
  134. +
  135. [source,console]
  136. ----
  137. POST /my-index-000001/_doc
  138. {
  139. "@timestamp": "2019-05-18T15:57:27.541Z",
  140. "ip": "225.44.217.191",
  141. "extension": "jpg",
  142. "response": "200",
  143. "geo": {
  144. "coordinates": {
  145. "lat": 38.53146222,
  146. "lon": -121.7864906
  147. }
  148. },
  149. "url": "https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/charles-fullerton.jpg"
  150. }
  151. POST /my-index-000002/_doc
  152. {
  153. "@timestamp": "2019-05-20T03:44:20.844Z",
  154. "ip": "198.247.165.49",
  155. "extension": "php",
  156. "response": "200",
  157. "geo": {
  158. "coordinates": {
  159. "lat": 37.13189556,
  160. "lon": -76.4929875
  161. }
  162. },
  163. "memory": 241720,
  164. "url": "https://theacademyofperformingartsandscience.org/people/type:astronauts/name:laurel-b-clark/profile"
  165. }
  166. ----
  167. . Use the <<indices-get-index,get index API>> to view the configurations for the
  168. new indices. The indices were configured using the index template you created
  169. earlier.
  170. +
  171. [source,console]
  172. --------------------------------------------------
  173. GET /my-index-000001,my-index-000002
  174. --------------------------------------------------
  175. // TEST[continued]
  176. [float]
  177. [[manage-enrich-policies]]
  178. === Manage enrich policies
  179. Use the *Enrich Policies* view to add data from your existing indices to incoming documents during ingest.
  180. An enrich policy contains:
  181. * The policy type that determines how the policy matches the enrich data to incoming documents
  182. * The source indices that store enrich data as documents
  183. * The fields from the source indices used to match incoming documents
  184. * The enrich fields containing enrich data from the source indices that you want to add to incoming documents
  185. * An optional <<query-dsl-match-all-query,query>>.
  186. [role="screenshot"]
  187. image::images/index-mgmt/management-enrich-policies.png[Enrich policies]
  188. When creating an enrich policy, the UI walks you through the configuration setup and selecting the fields.
  189. Before you can use the policy with an enrich processor or {esql} query, you must execute the policy.
  190. When executed, an enrich policy uses enrich data from the policy’s source indices
  191. to create a streamlined system index called the enrich index. The policy uses this index to match and enrich incoming documents.
  192. Check out these examples:
  193. * <<geo-match-enrich-policy-type>>
  194. * <<match-enrich-policy-type>>
  195. * <<range-enrich-policy-type>>