Reduce storageedit

The amount of storage for APM data depends on several factors: the number of services you are instrumenting, how much traffic the services see, agent and server settings, and the length of time you store your data.

Reduce the sample rateedit

The transaction sample rate directly influences the number of documents (more precisely, spans) to be indexed. It is the easiest way to reduce storage.

The transaction sample rate is a configuration setting of each agent. Reducing it does not affect the collection of metrics such as Transactions per second.

Reduce collected stacktrace informationedit

Elastic APM agents collect stacktrace information under certain circumstances. This can be very helpful in identifying issues in your code, but it also comes with an overhead at collection time and increases the storage usage.

Stacktrace collection settings are managed in each agent.

Delete dataedit

You might want to only keep data for a defined time period. This might mean deleting old documents periodically, deleting data collected for specific services or customers, or deleting specific indices.

Depending on your use case, you can delete data periodically with index lifecycle management, Curator, the Delete By Query API, or in the Kibana Index Management UI.

Delete data with ILMedit

Index Lifecycle management (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. See Customize index lifecycle management to learn more.

Delete data periodicallyedit

To delete data periodically you can use Curator and set up a cron job to run it.

By default, APM indices have the pattern apm-%{[observer.version]}-{type}-%{+yyyy.MM.dd}. With the curator command line interface you can, for instance, see all your existing indices:

curator_cli --host localhost show_indices --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"apm-"}]'

apm-7.10.2-error-2019.10.20
apm-7.10.2-error-2019.10.21
apm-7.10.2-error-2019.10.22
apm-7.10.2-sourcemap
apm-7.10.2-span-2019.10.20
apm-7.10.2-span-2019.10.21
apm-7.10.2-span-2019.10.22
apm-7.10.2-transaction-2019.10.20
apm-7.10.2-transaction-2019.10.21
apm-7.10.2-transaction-2019.10.22

And then delete any span indices older than 1 day:

curator_cli --host localhost delete_indices --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"apm-7.10.2-span-"}, {"filtertype":"age","source":"name","timestring":"%Y.%m.%d","unit":"days","unit_count":1,"direction":"older"}]'

INFO      Deleting selected indices: [apm-7.10.2-span-2019.10.20, apm-7.10.2-span-2019.10.21]
INFO      ---deleting index apm-7.10.2-span-2019.10.20
INFO      ---deleting index apm-7.10.2-span-2019.10.21
INFO      "delete_indices" action completed.
Delete data matching a queryedit

You can delete documents matching a specific query. For example, all documents with a given c`ontext.service.name use the following request:

POST /apm-*/_delete_by_query
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "context.service.name": {
              "value": "old-service-name"
            }
          }
        }
      ]
    }
  }
}

See delete by query for further information on this topic.

Delete data via Kibana Index Management UIedit

Select the indices you want to delete, and click Manage indices to see the available actions. Then click delete indices.