Managing HEAL OpenSearch Index State Management (ISM) Policies
Creating, retrieving, deleting and updating ISM policies, including removing a policy from indices and reattaching it.
ISM policies help manage the lifecycle of OpenSearch indices, such as deleting old indices based on their age.
Currently, HEAL utilizes a single ISM policy for both raw KPI and TXN indices, which removes data older than 1 day.
To enable the viewing of the last 24 hours of transaction response time percentile data, it is necessary to implement separate ISM policies:
- 1-day retention policy for KPI indices, and
- 7-day retention policy for transaction indices.
This configuration is recommended specifically for HEAL users who are interested in analyzing the transaction response time percentile data from the most recent 24-hour period within a 1-week time frame.
To change a policy that is already applied to indexes (for example, its min_index_age), see Updating an Existing ISM Policy.
Creating or Updating ISM Policies#
To efficiently manage the lifecycle of OpenSearch indices in the HEAL software, create or update ISM policies by following the process outlined below.
Raw_KPI Indices#
To create or update the ISM policy for indices with the "heal_raw_kpi_*" pattern, use the following command. This policy will delete indices older than 1 day.
curl -ku [USERNAME]:[PASSWORD] -XPUT
"[OPENSEARCH_URL]/_plugins/_ism/policies/ism_raw_kpi_indexes" -H 'Content-Type:
application/json' -d'{"policy": {"description": "Policy that deletes indices older than
1day","schema_version": 1,"error_notification": null,"default_state": "open","states": [{"name":
"open","actions": [{"open": {}}],"transitions": [{"state_name": "delete","conditions":
{"min_index_age": "1d"}}]},{"name": "delete","actions": [{"delete": {}}],"transitions":
[]}],"ism_template": {"index_patterns": [ "heal_raw_kpi_*"],"priority": 2}}}'
Note: Replace [OPENSEARCH_URL], [USERNAME], and [PASSWORD] with your specific OpenSearch instance URL, username, and password.
Raw_txn Indices#
To create or update the ISM policy for indices with the "heal_raw_txn_*" pattern, use the following command. This policy will delete indices older than 7 days.
curl -ku [USERNAME]:[PASSWORD] -XPUT
"[OPENSEARCH_URL]/_plugins/_ism/policies/ism_raw_txn_indexes" -H 'Content-Type:
application/json' -d'{"policy": {"description": "Policy that deletes indices older than
7days","schema_version": 1,"error_notification": null,"default_state": "open","states": [{"name":
"open","actions": [{"open": {}}],"transitions": [{"state_name": "delete","conditions":
{"min_index_age": "7d"}}]},{"name": "delete","actions": [{"delete": {}}],"transitions":
[]}],"ism_template": {"index_patterns": [ "heal_raw_txn_*"],"priority": 2}}}'
Note: Replace [OPENSEARCH_URL], [USERNAME], and [PASSWORD] with your specific OpenSearch instance URL, username, and password.
Retrieving ISM Policies#
To obtain the current ISM policies for the HEAL OpenSearch indices, follow the steps below to retrieve the Raw_KPI and Raw_txn policies using the appropriate commands.
Raw_KPI Indices#
To fetch the ISM policy for the Raw_KPI indices, use the following command:
curl -XGET "[OPENSEARCH_URL]/_plugins/_ism/policies/ism_raw_kpi_indexes"
Note: Replace [OPENSEARCH_URL] with your specific OpenSearch instance URL.
Raw_txn Indices#
To fetch the ISM policy for the Raw_txn indices, use the following command:
curl -XGET "[OPENSEARCH_URL]/_plugins/_ism/policies/ism_raw_txn_indexes"
Note: Replace [OPENSEARCH_URL] with your specific OpenSearch instance URL.
Deleting Existing ISM Policies#
Before applying new policies, you must delete the existing "ism_raw_indexes" policy. Use the following command to delete the policy:
curl -XDELETE "[OPENSEARCH_URL]/_plugins/_ism/policies/ism_raw_indexes"
Note: Replace [OPENSEARCH_URL] with your specific OpenSearch instance URL. The newly implemented policies will only take effect from the moment they are applied.
Updating an Existing ISM Policy#
When an ISM policy requires an update, follow these steps.
In the commands below, replace <uname> and <passwd> with your OpenSearch username and password, OpensearchIP (or <OpenSearchIP>) and port with your OpenSearch IP address and port, <policy_id> with the ISM policy, and <index_pattern> with the indexes that the policy applies to.
1. Remove the ISM policy from the indexes that require an update.
curl -ku <uname>:<passwd> -XPOST "https://OpensearchIP:port/_plugins/_ism/remove/<index_pattern>"
For example:
curl -ku <uname>:<passwd> -XPOST "https://OpensearchIP:port/_plugins/_ism/remove/heal_collated_*"
Expected output:
{"updated_indices":1,"failures":false,"failed_indices":[]}
Note: Updated_indices value may differ based on the index pattern you choose.
2. Back up and delete the old policy.
a. Fetch the current policy so the JSON can be saved before deletion.
curl -ku <uname>:<passwd> -XGET "https://<OpenSearchIP>:<port>/_plugins/_ism/policies/<policy_id>"
b. Delete the policy to prepare for recreating it with a new min_index_age.
curl -ku <uname>:<passwd> -XDELETE "https://<OpenSearchIP>:<port>/_plugins/_ism/policies/<policy_id>"
For example:
curl -ku <uname>:<passwd> -XDELETE "https://<OpenSearchIP>:<port>/_plugins/_ism/policies/ism_error_indexes"
Expected output:
{"_index":".opendistro-ism-config","_type":"_doc","_id":"ism_error_indexes","_version":8,
"result":"deleted","forced_refresh":true,"_shards":{"total":2,"successful":2,"failed":0},
"_seq_no":265797,"_primary_term":3}
3. Recreate the policy with the new min_index_age:
Create the same policy ID with the updated min_index_age in the transitions section.
curl -ku <uname>:<passwd> -XPUT "https://OpensearchIP:port/_plugins/_ism/policies/<policy_id>" -H 'Content-Type:application/json' -d'{<body>}'
For example:
curl -ku <uname>:<passwd> -XPUT "https://OpensearchIP:port/_plugins/_ism/policies/
ism_error_indexes" -H 'Content-Type: application/json' -d'{"policy" : { "description" :
"Policy that deletes indices older than 30d.", "schema_version" : 13, "error_notification" :
null, "default_state" : "open", "states" : [ { "name" : "open", "actions" : [ { "open" :
{ } } ], "transitions" : [ { "state_name" : "delete", "conditions" : { "min_index_age" :
"30d" } } ] }, { "name" : "delete", "actions" : [ { "delete" : { } } ], "transitions" :
[ ] } ], "ism_template" : [ { "index_patterns" : [ "heal_error_kpi_*" ], "priority" : 2
} ] }}'
Expected output:
{"_id":"ism_error_indexes","_version":1,"_primary_term":3,"_seq_no":265826,
"policy":{"policy":{"policy_id":"ism_error_indexes","description":"Policy
that deletes indices older than 30d.","last_updated_time":1695382477181,
"schema_version":13,"error_notification":null,"default_state":"open",
"states":[{"name":"open","actions":[{"retry":{"count":3,"backoff":"exponential",
"delay":"1m"},"open":{}}],"transitions":[{"state_name":"delete",
"conditions":{"min_index_age":"30d"}}]},{"name":"delete","actions":
[{"retry":{"count":3,"backoff":"exponential","delay":"1m"},"delete":{}}],
"transitions":[]}],"ism_template":[{"index_patterns":"heal_error_kpi_*"],
"priority":2,"last_updated_time":1695382477181}]}}}
4. Reattach the policy to the indexes:
Add the updated policy back to the required indexes or patterns.
curl -ku <uname>:<passwd> -XPOST "https://OpensearchIP:port/_plugins/_ism/add/<index_pattern>"
-H 'Content-Type: application/json' -d'{ "policy_id": "your_policy_id"}'
Note: The "your_policy_id" refers to which ISM policy the index should be mapped to.
Expected output:
{"updated_indices":1,"failures":false,"failed_indices":[]}
5. Verify policy application:
Check the ISM status on the affected indexes to confirm the current state and active policy.
curl -ku <uname>:<passwd> -XGET "https://<OpenSearchIP>:<port>/_plugins/_ism/explain/<index_pattern>"
a. This command displays the current status of ISM operations for the given index patterns.
Note: Some ISM policies specify multiple patterns in the index_patterns field.
For example: ism_collated_indexes covers heal_collated_kpi_*, heal_collated_txn_*, heal_collated_agent_txn_*
b. Therefore, use a broader pattern such as heal_collated_* to update all of these indexes with a single command.
c. If patterns differ, update each index (or pattern) individually with the relevant index_patterns value.
Related#
- Before you restore Jaeger snapshots on another cluster, ensure that the restore cluster's Jaeger ISM policy has the required retention duration. See Jaeger Trace Snapshot and Restore through NFS Mount.
- If setting an ISM policy fails with an error, see Error Occurred while setting ISM Policy for Data Retention in OpenSearch.