---
version: ${xpack.apmdata.template.version}
_meta:
  managed: true
description: |
  Built-in default ingest pipeline for metrics-apm.internal-* data streams.

  This pipeline exists purely for routing, which cannot be
  performed in a final pipeline, and for invoking user-defined
  custom pipelines. All built-in processing occurs in the final
  pipelines.
processors:
  # Older versions of apm-server write various metrics to the
  # metrics-apm.internal data stream, which newer versions break
  # into separate datasets. We reroute these metrics coming from
  # older versions of apm-server based on 'metricset.name'.
- set:
    if: "ctx.metricset?.name == 'transaction' || ctx.metricset?.name == 'service_destination'"
    field: metricset.interval
    value: 1m
    override: false
- reroute:
    if: "ctx.metricset?.name == 'transaction'"
    dataset: apm.transaction.1m
- reroute:
    if: "ctx.metricset?.name == 'service_destination'"
    dataset: apm.service_destination.1m

# Invoke user-defined custom pipelines, in ascending order of specificity:
- pipeline:
    name: global@custom
    ignore_missing_pipeline: true
- pipeline:
    name: metrics@custom
    ignore_missing_pipeline: true
- pipeline:
    name: metrics-apm.internal@custom
    ignore_missing_pipeline: true
