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