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

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"]
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:

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

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 for setting up automatic rollover based on dates, managed by Elasticsearch itself.

Hopefully with both approaches you can get a complete solution!

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

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