Manual index lifecycle management
editManual index lifecycle management
editAPM Server can take advantage of the index lifecycle management (ILM) capabilities of Elasticsearch. ILM enables you to automate how you want to manage your indices over time. You can base actions on factors such as shard size and performance requirements.
The guide below will help you set up a custom ILM policy for span indices. You can repeat the actions for any other indices.
If you’re migrating from an existing setup, any indices present before ILM was configured will need to be managed manually.
-
Set up the default index template.
If you haven’t already, you’ll need to set up the default index template. This is accomplished by running the
setup --template
command../apm-server setup --template
-
Create a policy for spans.
Index lifecycle management will manage an index based on its defined policy. Policies only need to be created once, and will persist through version upgrades. Let’s create a policy named
apm_span_policy
.This policy defines two rollover criteria:
"max_age": "1d"
, and"max_size": "50gb"
. When one or more of these criteria are met, the policy rolls data over into a new index.apm_span_policy
also tells the old indexes to delete after 10 days. All of these values can be customized to your specific needs. -
Set up the ILM index template.
To use the index lifecycle management policy created in the previous step, you need to specify it in the index template used to create the indices. The following template associates
apm_span_policy
with indices created from theapm-7.0.1-span-ilm
template.Because we’re utilizing the current stack-version (7.0.1) in this step, this action will need to be performed as a part of each version upgrade.
-
Create the index and alias.
Now we can create the first index:
apm-7.0.1-span-000001
.This action will need to be performed as a part of each version upgrade.
-
Verify the ILM index template was applied.
GET apm-*-span/_settings
The response should be similar to this:
{ "apm-7.0.1-span-000001" : { "settings" : { "index" : { "lifecycle" : { "name" : "apm_span_policy", "rollover_alias" : "apm-7.0.1-span" }, "number_of_shards" : "1", "provided_name" : "apm-7.0.1-span-000001", "creation_date" : "1553024227938", "number_of_replicas" : "1", "uuid" : "6b5l-H7QTRK95FAodAN-wg", "version" : { "created" : "7000099" } } } } }
You can also verify and adjust your configuration via Kibana’s management.
-
Repeat for other indices.
Repeat the previous steps for each index that will be using ILM.
- Create a policy
- Set up the ILM index template
- Create the index and alias
- Verify the ILM index template was applied
-
Modify APM Server’s configuration.
Finally, modify the default index configuration in
apm-server.yml
. Trim off the date template from each index you are setting up ILM for, so that APM Server is always writing events to the same place. The name of your modified index configuration must match theis_write_index
alias created previouslyIt’s important to note that
apm-server.yml
overwrites defaults rather than being merged. This means you’ll need to configure all of your indices in the file, even if some are not using ILM.output.elasticsearch: indices: - index: "apm-7.0.1-sourcemap" when.contains: processor.event: "sourcemap" - index: "apm-7.0.1-error" when.contains: processor.event: "error" - index: "apm-7.0.1-transaction" when.contains: processor.event: "transaction" - index: "apm-7.0.1-span" when.contains: processor.event: "span" - index: "apm-7.0.1-metric" when.contains: processor.event: "metric" - index: "apm-7.0.1-onboarding" when.contains: processor.event: "onboarding"
-
Start apm-server.
Your ILM configuration should now be up and running!
-
Monitor ILM status as events flow:
GET apm-*/_ilm/explain?human
-
Monitor index status:
GET _cat/indices/apm*?v
-