# Is it possible to use the metadata processors for an apm server same as in the filebeat config

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863>\
**Category:** APM\
**Tags:** server\
**Created:** [May 22, 2020, 8:10am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863 "2020-05-22T08:10:22Z")\
**Posts on this page:** 6\
**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:** [May 22, 2020, 8:10am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/1 "2020-05-22T08:10:22Z")

</div>

Is it possible to create indices for my apm agent like this using the processors add metadata option? And if its possible where do I adjust the settings? Have not found any example of a kubernetes yaml in the apm github repository.  
Thanks a lot!

```auto
filebeatConfig:
      filebeat.yml: |
        processors:
        - add_cloud_metadata:
        - add_kubernetes_metadata:
            in_cluster: true
            matchers:
              - logs_path:
                  logs_path: "/var/lib/docker/containers/"

        output.elasticsearch:
          hosts: 'https://elasticsearch-master:9200'
          username: '${ELASTICSEARCH_USERNAME}'
          password: '${ELASTICSEARCH_PASSWORD}'
          index: "default-logs-%{[agent.version]}-rollover"
          indices:
          - index: "%{[kubernetes.namespace]:-}-k8s-logs-%{[agent.version]}-rollover"
            when.has_fields: ['kubernetes.namespace']

```

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [May 25, 2020, 1:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/2 "2020-05-25T01:23:35Z")

</div>

Yes, those processors are supported in apm-server too. You configure them just the same as in filebeat, only you put them in `apm-server.yml` instead of `filebeat.yml`.

> Have not found any example of a kubernetes yaml in the apm github repository.

No, there isn't one in the repo, and I'm not sure where you can find one. Perhaps someone else can chime in. In case they're of use to you, there is a [Helm chart](https://github.com/elastic/helm-charts/tree/master/apm-server), and Elastic Cloud on Kubernetes (ECK) supports [APM Server orchestration](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-apm-server.html).

---

<div class="post-metadata">

**Author:** ![pabloborh](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pabloborh](https://discuss.elastic.co/u/pabloborh)\
**Post date:** [June 3, 2020, 10:58am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/3 "2020-06-03T10:58:40Z")

</div>

Hi @elk51211 Can you put the yaml of the apm-server? I can't make it work.

Thanks

---

<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:** [June 4, 2020, 7:45am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/4 "2020-06-04T07:45:44Z")

</div>

Sure! That worked for me.

```auto
  apm-server.yml: |
    apm-server:
      host: "0.0.0.0:8200"
    setup:
      template:
        name: "apm-%{[observer.version]}"
        pattern: "*-apm-%{[observer.version]}-*"
    
    # add processors to get metadata on kubernetes namespaces
    processors:
      - add_cloud_metadata:
      - add_kubernetes_metadata:
          in_cluster: true
          matchers:
            - logs_path:
                logs_path: "/var/lib/docker/containers/"
    queue: {}
    output.elasticsearch:
      username: '${ELASTICSEARCH_USERNAME}'
      password: '${ELASTICSEARCH_PASSWORD}'
      index: "default-apm-%{[observer.version]}"
      indices:
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-sourcemap"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "sourcemap"
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-error-%{+yyyy.MM.dd}"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "error"
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-transaction-%{+yyyy.MM.dd}"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "transaction"
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-span-%{+yyyy.MM.dd}"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "span"
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-metric-%{+yyyy.MM.dd}"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "metric"
        - index: "%{[kubernetes.namespace]:-}-apm-%{[observer.version]}-onboarding-%{+yyyy.MM.dd}"
          when.has_fields: ['kubernetes.namespace']
          when.contains:
            processor.event: "onboarding"
      protocol: https
      hosts: ["elasticsearch-master:9200"]
      ssl.certificate_authorities:
        - /usr/share/apm-server/config/certs/elastic-certificate.pem
secretMounts:
  - name: elastic-certificate-pem
    secretName: elastic-certificate-pem
    path: /usr/share/apm-server/config/certs

extraEnvs:
  - name: 'ELASTICSEARCH_USERNAME'
    valueFrom:
      secretKeyRef:
        name: elastic-credentials
        key: username
  - name: 'ELASTICSEARCH_PASSWORD'
    valueFrom:
      secretKeyRef:
        name: elastic-credentials
        key: password

```

---

<div class="post-metadata">

**Author:** ![pabloborh](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pabloborh](https://discuss.elastic.co/u/pabloborh)\
**Post date:** [June 4, 2020, 10:54am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/5 "2020-06-04T10:54:11Z")

</div>

Thanks @elk51211.

In my case is not working because I have Dynamic index setting to false.

Official doc say that dynamic setting is defined as true but i do not defined it in any place. Anyone know how to set it in the yaml config?

Thanks ^^

---

<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 25, 2020, 6:54am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-the-metadata-processors-for-an-apm-server-same-as-in-the-filebeat-config/233863/6 "2020-06-25T06:54:17Z")

</div>

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