# Dynamic namespace on APM integration

**URL:** <https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023>\
**Category:** APM\
**Tags:** fleet, server, integrations\
**Created:** [May 31, 2022, 9:46am UTC](https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023 "2022-05-31T09:46:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliana\_cg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juliana_cg/32/99127_2.png) [@juliana\_cg](https://discuss.elastic.co/u/juliana_cg)\
**Post date:** [May 31, 2022, 9:46am UTC](https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023/1 "2022-05-31T09:46:58Z")

</div>

Hello,

I'm using Fleet and Elastic Agent on ES 7.17.1. Before, we used an apm standalone server and we could decide how to name our indexes thanks to parameters on Elasticsearch output, like this:

```auto
  indices:
    - index: "apm-%{[observer.version]}-%{[kubernetes.namespace]}-error"
      when.contains:
        processor.event: "error"

    - index: "apm-%{[observer.version]}-%{[kubernetes.namespace]}-transaction"
      when.contains:
        processor.event: "transaction"

```

It seems this parameters no longer work on fleet Elasticsearch output configuration or on APM integration. I thought we could handle it with the namespace option of the APM integration, but it seems you can only define one namespace per apm.

Is there a way to set up namespace dynamically, so it can be equal to our kubernates namespace?

I've thought of manually setting up index name with ingest pipelines, but since we now use datastreams instead of indices i'm not sure it'll work as expected.

I've also wondered if using set processor to set datastream.namespace to kubernetes.namespace would correctly route de data to proper datastream, and if so, which of the many apm ingest pipelines should be edited.

Thanks!

---

<div class="post-metadata">

**Author:** ![stuart.nelson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stuart.nelson/32/99866_2.png) [@stuart.nelson](https://discuss.elastic.co/u/stuart.nelson)\
**Post date:** [June 1, 2022, 3:55pm UTC](https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023/2 "2022-06-01T15:55:05Z")

</div>

Hey, unfortunately this isn't supported due to limitation in the elastic-agent / fleet. You could definitely open a feature request in the [elastic-agent repository](https://github.com/elastic/elastic-agent). The best work-around at the moment is to have an agent policy per kubernetes namespace, and configure the apm integration with that desired namespace.

---

<div class="post-metadata">

**Author:** ![juliana\_cg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juliana_cg/32/99127_2.png) [@juliana\_cg](https://discuss.elastic.co/u/juliana_cg)\
**Post date:** [June 9, 2022, 3:45pm UTC](https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023/3 "2022-06-09T15:45:48Z")

</div>

I see, thanks for the suggestion. Do you think setting up an Elastic agent to output to logstash could also work out?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 30, 2022, 11:46am UTC](https://discuss.elastic.co/t/dynamic-namespace-on-apm-integration/306023/4 "2022-06-30T11:46:45Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
