# Error while fetching resource Kibana APM

**URL:** https://discuss.elastic.co/t/error-while-fetching-resource-kibana-apm/315284
**Category:** Elasticsearch
**Created:** [September 27, 2022, 3:30pm UTC](https://discuss.elastic.co/t/error-while-fetching-resource-kibana-apm/315284 "2022-09-27T15:30:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danksim](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@danksim](https://discuss.elastic.co/u/danksim)
#### Post date: [September 27, 2022, 3:30pm UTC](https://discuss.elastic.co/t/error-while-fetching-resource-kibana-apm/315284/1 "2022-09-27T15:30:43Z")

</div>

elasticsearch, logstash, kibana: 7.17.3  
apm-server: 7.5.2

I am getting the following error when trying to access the APM tab on Kibana:  
 ![Screen Shot 2022-09-23 at 10.53.15 AM](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9bffd95ddffb3cd94937f6b9be4d53f051d8a1e2.png)

```auto
Error while fetching resource
search_phase_execution_exception: [illegal_argument_exception] Reason: Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [service.name] in order to load field data by uninverting the inverted index. Note that this can use significant memory. (500)

```

This seems similar to the question [here](https://discuss.elastic.co/t/failed-to-load-resource-the-server-responded-with-a-status-of-500-internal-server-error/225612) but I don't have any of the setup process in `apm-server.yml` as I am writing directly to `kafka` (not `elasticsearch`) and `ilm setup` is all taken care by `logstash` (see below).

Background:  
I am using `apm-server` to output to a `kafka topic` named `apm-server` and I have `logstash` consume said `kafka topic` and output to `elasticsearch`.

`apm-server` config:

```auto
    # ensure only kafka output
    output.file:
      enabled: false
    output.console:
      enabled: false
    output.kafka:
      hosts: ["kafka-bootstrap.kafka:9092"]
      topic: apm-server
      key: '%{[processor.event,service.name,kubernetes.pod.uid]:default}'
      partition.hash:
        hash:
        - processor.event
        - service.name
        - kubernetes.pod.uid
        random: true
      compression: lz4

```

`output` piece of `logstash` pipeline:

```auto
    output {
      elasticsearch {
        hosts => ["https://elastic-stack-coordinator:9200"]
        ssl => true
        keystore => <REDACTED>
        keystore_password => <REDACTED>
        truststore => <REDACTED>
        truststore_password => <REDACTED>
        manage_template => false
        user => apm_writer
        password => <REDACTED>
        index => "apm-index"
        ilm_rollover_alias => "apm-index"
        ilm_pattern => "000001"
        ilm_policy => "apm-ilm"
        ilm_enabled => true
      }
    }

```

so when my `ELK` cluster starts, I end up with an `index` named `apm-index-000001` with `ilm_rollover_alias` `apm-index`.

This all works fine in dev (identical settings as test cluster) and prod clusters but does not in a third cluster I just setup.

---

<div class="post-metadata">

### Author: ![danksim](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@danksim](https://discuss.elastic.co/u/danksim)
#### Post date: [September 27, 2022, 4:07pm UTC](https://discuss.elastic.co/t/error-while-fetching-resource-kibana-apm/315284/2 "2022-09-27T16:07:55Z")

</div>

Ah my apologies. There is a `kubernetes job` that runs the following legacy `apm-server` `setup` command. This is a snippet from `helmfile sync`:

```auto
        args:
        - "setup"
        - "-e"
        - "--index-management"
        - "-E=setup.template.pattern='apm-*'"
        - "-E=setup.template.name='apm-ns'"
        - "-E=setup.template.overwrite='true'"
        - "-E=setup.template.settings={'index.max_docvalue_fields_search': '20000','index.number_of_shards': '6', 'index.refresh_interval': '60s','index.lifecycle.name': 'apm-ilm','index.lifecycle.rollover_alias': 'apm-index', 'index.translog.durability': 'async'}"
        - "-E=setup.template.append_fields=[{name:'labels.queue',type:'keyword'},{name:'labels.topic',type:'keyword'},{name:'http.request.headers',type:'object',dynamic:'true'},{name:'http.request.headers.Encrypted-User-Uuid',type:'keyword'},{name:'http.request.headers.X-Encrypted-User-Uuid',type:'keyword'},{name:'http.request.headers.X-App-Name',type:'keyword'}]"
        - "-E=output.elasticsearch.index='apm-%!{(MISSING)[kubernetes][namespace]}-%!{(MISSING)+MM.dd.YYYY}'"
        - "-E=output.elasticsearch.username=${ELK_USERNAME}"
        - "-E=output.elasticsearch.password=${ELK_PASSWORD}"
        - "-E=output.elasticsearch.ssl.certificate=/etc/elk/CA/tls.crt"
        - "-E=output.elasticsearch.ssl.key=/etc/elk/CA/tls.key"
        - "-E=output.elasticsearch.ssl.certificate_authorities=['/etc/elk/CA/ca.crt']"
        - "-E=output.elasticsearch.hosts=['https://elastic-stack-coordinator:9200']"

```

If I were to implement the following [fix](https://discuss.elastic.co/t/failed-to-load-resource-the-server-responded-with-a-status-of-500-internal-server-error/225612/8), how would I use the `setup` command?

 ![Screen Shot 2022-09-27 at 12.13.33 PM](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b93225b0c7daea3c20967078c47e472c51012807.png)  
It looks like `index.indices` but then it's a list with `- index`. Am I able to do `-E=output.elasticsearch.index.indices.index=<some-index>`?

---

<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: [October 25, 2022, 4:07pm UTC](https://discuss.elastic.co/t/error-while-fetching-resource-kibana-apm/315284/3 "2022-10-25T16:07:57Z")

</div>

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