# Sending HTTP error to APM from Angular shows error.custom.\<name\> field in Kibana

**URL:** <https://discuss.elastic.co/t/sending-http-error-to-apm-from-angular-shows-error-custom-name-field-in-kibana/231898>\
**Category:** APM\
**Tags:** rum\
**Created:** [May 10, 2020, 5:38pm UTC](https://discuss.elastic.co/t/sending-http-error-to-apm-from-angular-shows-error-custom-name-field-in-kibana/231898 "2020-05-10T17:38:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edarioq](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@edarioq](https://discuss.elastic.co/u/edarioq)\
**Post date:** [May 10, 2020, 5:38pm UTC](https://discuss.elastic.co/t/sending-http-error-to-apm-from-angular-shows-error-custom-name-field-in-kibana/231898/1 "2020-05-10T17:38:33Z")

</div>

**Kibana version** : 7.6.2

**Elasticsearch version** : 7.6.2

**APM Server version** : 7.6.2

**APM Agent language and version** : `@elastic/apm-rum-angular` 1.1.1. Angular 9.1.0

**Browser version** : Firefox 76.0b8

**Original install method (e.g. download page, yum, deb, from source, etc.) and version** : Used the [Angular Integration](https://www.elastic.co/guide/en/apm/agent/rum-js/master/angular-integration.html) instructions

While trying to Query Kibana for HTTP status code error, I see that these `custom` fields are not indexed and thus not filterable. It's weird that these even show up as `custom` at all, I would imagine that Elastic should know that these are HTTP errors and would match it accordingly to a field in Kibana.

See image, note `error.custom.<name>` (why are these being created?):

 ![Screen Shot 2020-05-10 at 12.31.07 PM](https://us1.discourse-cdn.com/elastic/original/3X/a/2/a2a1f51c5569fc3290ab235a275eb612ea61d4bb.png)

This is how I'm sending the error from Angular:

```auto
constructor(@Inject(ApmService) service: ApmService) {
    this.apmService = service.init({
      serviceName: 'frontend',
      serverUrl: 'http://localhost:8200/',
      serviceVersion: '1.0.0',
    });

    this.apmService.setUserContext({
      username: 'John',
      id: '001',
    });
  }

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    return next.handle(req).pipe(
      retry(1),
      catchError((error: HttpErrorResponse) => {
        let errorMessage = '';
        if (error.error instanceof ErrorEvent) {
          // client-side error
          errorMessage = `Error: ${error.error.message}`;
        } else {
          // server-side error
          errorMessage = `Error: ${error.status} - ${error.message}`;
        }
        this.apmService.captureError(error, { response: error.status });
        return throwError(errorMessage);
      })
    );
  }

```

How do I send this error to APM so that Kibana correctly knows to fill this in with the correct fields it has?

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [May 11, 2020, 8:44am UTC](https://discuss.elastic.co/t/sending-http-error-to-apm-from-angular-shows-error-custom-name-field-in-kibana/231898/2 "2020-05-11T08:44:11Z")

</div>

Hi Edgar,

The Angular Error type `HTTPErrorrResponse` is a custom one and has many properties that does not match with the common Error format which has `name`,`message`, `stack`, `columnno`, `lineno` and so on. The common error properties are indexed correctly to `exception` which is already defined mapping. All the other error properties are intentionally added to the `custom` context as it would help the users to debug the issues faster.

There is no special treatment given to the HTTP based errors at this point in the APM server as of this date. As you have mentioned already, the custom context is not indexed as it can contain arbitrary information which might not be useful in all scenarios.

To go back to how we can do this correctly, 404 is a valid response and the HTTP span would contain all the information related to the request (eg: status, url etc). Hope it helps. Let me know if you have any further questions.

Thanks,  
Vignesh

---

<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 1, 2020, 4:44am UTC](https://discuss.elastic.co/t/sending-http-error-to-apm-from-angular-shows-error-custom-name-field-in-kibana/231898/3 "2020-06-01T04:44:15Z")

</div>

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