Files
doc-exports/docs/css/umn/css_01_0419.html
zhengxiu 2125539080 css umn 25.1.0 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: zhengxiu <zhengxiu@huawei.com>
Co-committed-by: zhengxiu <zhengxiu@huawei.com>
2025-07-04 09:10:17 +00:00

48 lines
12 KiB
HTML

<a name="css_01_0419"></a><a name="css_01_0419"></a>
<h1 class="topictitle1">Creating and Managing Index Policies for an Elasticsearch Cluster</h1>
<div id="body1606731388435"><p id="css_01_0419__p17682103664518">This topic describes how to create and manage index lifecycle policies for Elasticsearch clusters.</p>
<div class="section" id="css_01_0419__section570781916170"><h4 class="sectiontitle">Context</h4><p id="css_01_0419__p9627569502">Index State Management (ISM) of Elasticsearch is a plugin that allows you to automate periodic, administrative operations on indexes by triggering them based on changes in the index age, index size, or number of documents. With ISM, you can define custom policies to automate index rollovers and deletion, thus optimizing cluster search performance or cutting storage costs. The procedure for using ISM is as follows:</p>
<ol id="css_01_0419__ol182015215117"><li id="css_01_0419__li202010218518"><a href="#css_01_0419__en-us_topic_0000001268154473_section779154094817">Creating an Index Lifecycle Policy</a>: Create an index lifecycle policy on OpenSearch Dashboards.</li><li id="css_01_0419__li695231615510"><a href="#css_01_0419__en-us_topic_0000001268154473_section11451321182815">Associating Indexes with a Lifecycle Policy</a>: Associate indexes with a lifecycle policy.</li><li id="css_01_0419__li148518914513"><a href="#css_01_0419__en-us_topic_0000001268154473_section87941257192">Managing Index Policies</a>: Modify, retry, and change index lifecycle policies.</li></ol>
<p id="css_01_0419__p18766571223">For more information about ISM, see <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/im/ism/" target="_blank" rel="noopener noreferrer">Index State Management</a>.</p>
<p id="css_01_0419__p284113182719">Common use cases for index lifecycle policies:</p>
<ul id="css_01_0419__ul1850994172715"><li id="css_01_0419__li10509184192716"><a href="css_01_0420.html">Automating Index Rollover in an Elasticsearch Cluster Through Index Lifecycle Management</a></li><li id="css_01_0419__li205093432718"><a href="css_01_0421.html">Decoupling Index Storage and Compute in an Elasticsearch Cluster Through Index Lifecycle Management</a></li></ul>
</div>
<div class="section" id="css_01_0419__section10503166419"><h4 class="sectiontitle">Constraints</h4><ul id="css_01_0419__ul282918281842"><li id="css_01_0419__li14462138665">ISM is available only in Elasticsearch 7.6.2 clusters or later or OpenSearch clusters.</li><li id="css_01_0419__li582920289419">You can customize policy names in Kibana.</li><li id="css_01_0419__li108294287419">The Kibana GUI varies depending on the Kibana version. Kibana 7.6.2 is used as an example here.</li></ul>
</div>
<div class="section" id="css_01_0419__en-us_topic_0000001268154473_section779154094817"><a name="css_01_0419__en-us_topic_0000001268154473_section779154094817"></a><a name="en-us_topic_0000001268154473_section779154094817"></a><h4 class="sectiontitle">Creating an Index Lifecycle Policy</h4><ol id="css_01_0419__en-us_topic_0000001268154473_ol1881418555550"><li id="css_01_0419__li8872182414613">Log in to the CSS management console.</li><li id="css_01_0419__li8978162804611">On the <span class="uicontrol" id="css_01_0419__uicontrol14514192571910"><b>Clusters</b></span> page, locate the target cluster, and click <span class="parmvalue" id="css_01_0419__parmvalue185151425131914"><b>Access Kibana</b></span> in the <span class="uicontrol" id="css_01_0419__uicontrol95156257193"><b>Operation</b></span> column to log in to the Kibana page.</li><li id="css_01_0419__en-us_topic_0000001268154473_li18815455105512">Choose <strong id="css_01_0419__b25778281205">IM</strong> or <strong id="css_01_0419__b10146123216207">Index Management</strong> from the menu bar to go to the index management page.</li><li id="css_01_0419__en-us_topic_0000001268154473_li6804104711597">Click <strong id="css_01_0419__b8936159182014">Create policy</strong> to configure an index lifecycle policy.<ul id="css_01_0419__ul226466194715"><li id="css_01_0419__li12459122884713"><span class="parmname" id="css_01_0419__parmname1102005413"><b>Policy ID</b></span>: use a custom policy name.</li><li id="css_01_0419__li426586144717"><span class="parmname" id="css_01_0419__parmname108321546544"><b>Define policy</b></span>: define a custom policy based on the reference example provided.</li></ul>
<div class="fignone" id="css_01_0419__en-us_topic_0000001268154473_fig11427149204015"><span class="figcap"><b>Figure 1 </b>Configuring a policy</span><br><span><img id="css_01_0419__en-us_topic_0000001268154473_image318610322918" src="en-us_image_0000001938378248.png"></span></div>
</li><li id="css_01_0419__en-us_topic_0000001268154473_li652213431799">Click <strong id="css_01_0419__en-us_topic_0000001268154473_b996810391201">Create</strong>.</li></ol>
</div>
<div class="section" id="css_01_0419__en-us_topic_0000001268154473_section11451321182815"><a name="css_01_0419__en-us_topic_0000001268154473_section11451321182815"></a><a name="en-us_topic_0000001268154473_section11451321182815"></a><h4 class="sectiontitle">Associating Indexes with a Lifecycle Policy</h4><p id="css_01_0419__en-us_topic_0000001268154473_p85771435104818">You can attach a policy to one or more indexes, or associate a policy with an index template, so that the policy will be applied to all indexes created using this index template.</p>
<p id="css_01_0419__p152519585468">Use either of the following methods to associate a lifecycle policy with an index.</p>
<ul id="css_01_0419__en-us_topic_0000001268154473_ul14378105912527"><li id="css_01_0419__en-us_topic_0000001268154473_li6378185910526"><strong id="css_01_0419__en-us_topic_0000001268154473_b1875164612020">Method 1: Kibana commands</strong><p id="css_01_0419__en-us_topic_0000001268154473_p193161652175311">On the <span class="uicontrol" id="css_01_0419__en-us_topic_0000001268154473_uicontrol127491655488"><b>Dev Tools</b></span> page of Kibana, run the following command to associate a policy ID with an index template:</p>
<pre class="screen" id="css_01_0419__en-us_topic_0000001268154473_screen25651257165413">PUT _template/<em id="css_01_0419__en-us_topic_0000001268154473_i2566165715544">&lt;template_name&gt;</em><strong id="css_01_0419__en-us_topic_0000001268154473_b1756635712545"> </strong>
{
"index_patterns": ["index_name-*"],
"settings": {
"opendistro.index_state_management.policy_id": "<em id="css_01_0419__en-us_topic_0000001268154473_i13566185719549">policy_id</em>"
}
}</pre>
<ul id="css_01_0419__en-us_topic_0000001268154473_ul2017887556"><li id="css_01_0419__en-us_topic_0000001268154473_li5171383553"><em id="css_01_0419__en-us_topic_0000001268154473_i15841845106"><strong id="css_01_0419__en-us_topic_0000001268154473_b85016441206">&lt;template_name&gt;</strong></em>: Replace it with the name of a created index template.</li><li id="css_01_0419__en-us_topic_0000001268154473_li161711813558"><em id="css_01_0419__i14774185622614"><strong id="css_01_0419__b2077435652618">policy_id</strong></em>: Replace it with a custom policy ID.</li></ul>
<p id="css_01_0419__en-us_topic_0000001268154473_p14340164895514">For details about how to create an index template, see <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/elasticsearch/index-templates/#create-template" target="_blank" rel="noopener noreferrer">Index Template</a>.</p>
</li><li id="css_01_0419__en-us_topic_0000001268154473_li1055631185314"><strong id="css_01_0419__en-us_topic_0000001268154473_b10250910022">Method 2: Kibana console</strong><ol id="css_01_0419__en-us_topic_0000001268154473_ol1325191810517"><li id="css_01_0419__li183821421115510">On the Kibana console, choose <strong id="css_01_0419__b595817377276">IM</strong> or <strong id="css_01_0419__b19958237142714">Index Management</strong> from the menu bar to go to the index management page.</li><li id="css_01_0419__en-us_topic_0000001268154473_li625119181453">Select <span class="uicontrol" id="css_01_0419__uicontrol14161057195512"><b>Indices</b></span> on the left.<div class="fignone" id="css_01_0419__en-us_topic_0000001268154473_fig1125113181451"><span class="figcap"><b>Figure 2 </b>Choosing Indices</span><br><span><img id="css_01_0419__en-us_topic_0000001268154473_image7252131816510" src="en-us_image_0000001938218884.png"></span></div>
</li><li id="css_01_0419__en-us_topic_0000001268154473_li1925216184512">In the <strong id="css_01_0419__en-us_topic_0000001268154473_b12310153193010">Indices</strong> list, select the target index to which you want to bind a policy.</li><li id="css_01_0419__en-us_topic_0000001268154473_li125212181054">Click <strong id="css_01_0419__b11941406864482">Apply policy</strong> in the upper right corner. In the displayed dialog box, select a policy ID.<div class="fignone" id="css_01_0419__en-us_topic_0000001268154473_fig625215181650"><span class="figcap"><b>Figure 3 </b>Adding an index policy</span><br><span><img id="css_01_0419__en-us_topic_0000001268154473_image625217181255" src="en-us_image_0000001965417249.png"></span></div>
<div class="fignone" id="css_01_0419__en-us_topic_0000001268154473_fig5252161812516"><span class="figcap"><b>Figure 4 </b>Selecting a policy</span><br><span><img id="css_01_0419__en-us_topic_0000001268154473_image725214188512" src="en-us_image_0000001965497453.png"></span></div>
</li><li id="css_01_0419__li669961645919">Click <strong id="css_01_0419__b115525354482">Apply</strong>.<p id="css_01_0419__p15699151665919">After you bind a policy to an index, ISM creates a job that runs every 5 minutes by default to execute the policy, check criteria, and change index states.</p>
</li></ol>
</li></ul>
</div>
<div class="section" id="css_01_0419__en-us_topic_0000001268154473_section87941257192"><a name="css_01_0419__en-us_topic_0000001268154473_section87941257192"></a><a name="en-us_topic_0000001268154473_section87941257192"></a><h4 class="sectiontitle">Managing Index Policies</h4><ol id="css_01_0419__ol16937161352812"><li id="css_01_0419__li183411772813">Log in to the CSS management console.</li><li id="css_01_0419__li1683411176287">On the <span class="uicontrol" id="css_01_0419__uicontrol969317716298"><b>Clusters</b></span> page, locate the target cluster, and click <span class="parmvalue" id="css_01_0419__parmvalue7693275299"><b>Access Kibana</b></span> in the <span class="uicontrol" id="css_01_0419__uicontrol126936710295"><b>Operation</b></span> column to log in to the Kibana page.</li><li id="css_01_0419__li178341917162820">Choose <strong id="css_01_0419__b16471138296">IM</strong> or <strong id="css_01_0419__b764721314296">Index Management</strong> from the menu bar to go to the index management page.</li><li id="css_01_0419__li68341517122813">Choose <span class="uicontrol" id="css_01_0419__uicontrol83514123298"><b>Managed Indices</b></span> on the left.<p id="css_01_0419__p10946547193112">The displayed page shows index policies configured for the current cluster.</p>
</li><li id="css_01_0419__li158123449312">Manage policies in the index policy list.<ul id="css_01_0419__ul9908193411329"><li id="css_01_0419__li590823415323">For a policy whose status is abnormal, click <strong id="css_01_0419__b2400479124482">Retry policy</strong>.</li><li id="css_01_0419__li15527184110338">To update a policy for an index, select the associated index, and click <strong id="css_01_0419__b18126758624482">Change policy</strong>. After the policy is updated, click <strong id="css_01_0419__b14206113244482">Change</strong> to apply the new policy.</li><li id="css_01_0419__li34482542391">To remove a policy from an index, select the index, and click <strong id="css_01_0419__b696953082912">Remove policy</strong>. In the displayed dialog box, click <strong id="css_01_0419__b11969830102919">Remove</strong>.</li></ul>
</li></ol>
<p id="css_01_0419__p75693302462">For details, see <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/im/ism/" target="_blank" rel="noopener noreferrer">Index State Management</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="css_01_0091.html">Managing Index Policies for an Elasticsearch Cluster</a></div>
</div>
</div>