# Is there a way to output the APM Agent/Server/App into specific kubernetes namespaces?

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399>\
**Category:** APM\
**Tags:** server\
**Created:** [April 23, 2020, 7:28am UTC](https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399 "2020-04-23T07:28:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elk51211](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@elk51211](https://discuss.elastic.co/u/elk51211)\
**Post date:** [April 23, 2020, 7:28am UTC](https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399/1 "2020-04-23T07:28:07Z")

</div>

Is there any way to output APM server into several elastic indices for every kubernetes namespace? I mean something like:

output.elasticsearch:  
hosts: ["[http://elasticsearch:9200](http://elasticsearch:9200)"]  
index: "apm-%{[namespace]}-%{+yyyy.MM.dd}-test"

Is there any way to accomplish this?  
And how do I adjust my kubernetes config file to output apm server to kubernetes namespaces:

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1

kind: Elasticsearch

metadata:

  name: elasticsearch

spec:

  version: 7.5.1

  nodeSets:

  - name: default

    count: 3

    config:

      node.master: true

      node.data: true

      node.ingest: true

      node.store.allow_mmap: false

---

apiVersion: kibana.k8s.elastic.co/v1

kind: Kibana

metadata:

  name: kibana

spec:

  version: 7.5.1

  count: 1

  elasticsearchRef:

    name: elasticsearch

---

apiVersion: apm.k8s.elastic.co/v1

kind: ApmServer

metadata:

  name: apm-server

spec:

  version: 7.5.1

  count: 1

  elasticsearchRef:

    name: "elasticsearch"

  config:

    apm-server:

      rum.enabled: true

      ilm.enabled: true

  http:

    service:

      spec:

        type: LoadBalancer

    tls:

      selfSignedCertificate:

        disabled: true

```

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [May 1, 2020, 1:59pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399/2 "2020-05-01T13:59:39Z")

</div>

Sorry, can't give you an exact k8s config right now, but am wondering about a general approach:

- if you used a configmap
- (regardless whether you generate configmaps or write them by hand) you would know which namespace the configmap is defined in
- so either as part of the manual or auto process for making configmaps, you can get `index: "apm-$namespace"` into the configmap

That leaves the date part. Have a look at [Index Lifecycle Management](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html) for setting up automatic rollover based on dates, managed by Elasticsearch itself.

Hopefully with both approaches you can get a complete solution!

---

<div class="post-metadata">

**Author:** ![elk51211](https://avatars.discourse-cdn.com/v4/letter/e/ccd318/32.png) [@elk51211](https://discuss.elastic.co/u/elk51211)\
**Post date:** [May 4, 2020, 10:53am UTC](https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399/3 "2020-05-04T10:53:57Z")

</div>

Where do I configure the configmap in my kubernetes.yaml?

---

<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:** [May 25, 2020, 6:53am UTC](https://discuss.elastic.co/t/is-there-a-way-to-output-the-apm-agent-server-app-into-specific-kubernetes-namespaces/229399/4 "2020-05-25T06:53:57Z")

</div>

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