# Sourcemaps not getting applied

**URL:** <https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923>\
**Category:** APM\
**Tags:** rum\
**Created:** [March 3, 2023, 9:28am UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923 "2023-03-03T09:28:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![skumar7](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@skumar7](https://discuss.elastic.co/u/skumar7)\
**Post date:** [March 3, 2023, 9:28am UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/1 "2023-03-03T09:28:21Z")

</div>

We have a custom node app for uploading source maps and have provided all the required details like serviceName, serviceVersion, bundlePath to upload. We are getting success message for all the source maps but when we try to retrieve we don't see the source maps available and also not getting applied to errors.

Getting hits as 0 for the query =\>

```auto
GET apm-*/_search
{
  "query": {
    "term": {
      "processor.event": "sourcemap"
    }
  }
}

```

```auto
{
  "took" : 37,
  "timed_out" : false,
  "_shards" : {
    "total" : 145,
    "successful" : 145,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  }
}

```

---

<div class="post-metadata">

**Author:** ![skumar7](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@skumar7](https://discuss.elastic.co/u/skumar7)\
**Post date:** [March 6, 2023, 3:25am UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/2 "2023-03-06T03:25:34Z")

</div>

Could somebody please help out, have been trying to fix this for quite some time

---

<div class="post-metadata">

**Author:** ![Alberto\_Delgado](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_delgado/32/98488_2.png) [@Alberto\_Delgado](https://discuss.elastic.co/u/Alberto_Delgado)\
**Post date:** [March 9, 2023, 5:32pm UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/3 "2023-03-09T17:32:23Z")

</div>

Hi @skumar7,

Thanks for using the RUM agent!

I have a few questions:

- What version of the RUM agent are you using?
- What version of the Elastic Stack are you using?
- Are you using the APM Server integration or the APM standalone server?
- Could you show us the code you are using to upload the source maps? (please redact the sensitive information)

Apart from that, I would like to share with you this post where we explain how to upload a sourcemap step by step: [Uploading sourcemaps from AIX webserver - #15 by Alberto\_Delgado](https://discuss.elastic.co/t/uploading-sourcemaps-from-aix-webserver/303526/15).

Cheers,  
Alberto

---

<div class="post-metadata">

**Author:** ![skumar7](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@skumar7](https://discuss.elastic.co/u/skumar7)\
**Post date:** [March 13, 2023, 7:13am UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/4 "2023-03-13T07:13:55Z")

</div>

Hi Alberto,

Please find the required details below:

- What version of the RUM agent are you using?  
agent

* * *

agent.name = rum-js  
agent.version = 5.11.1

- What version of the Elastic Stack are you using?  
elastic

* * *

observer.type = app-server  
observer.version = 7.17.3  
observer.version\_major = 7

- Are you using the APM Server integration or the APM standalone server?  
I think it is the APM standalone server but I am really not sure

## Code used for uploading source maps:

```auto
import fetch from 'isomorphic-fetch';
import path from 'path';
import git from 'git-rev-sync';
import * as fsp from 'fs/promises';
import FormData from 'form-data';

const uploadFile = async ({ filePath, bundlePath }) => {
    const fileContent = await fsp.readFile(filePath, { encoding: 'utf-8' });

    const formData = new FormData();
    formData.append('service_name', options.name);
    formData.append('service_version', git.long());
    formData.append('bundle_filepath', `/${bundlePath}`); 
    formData.append('sourcemap', fileContent);

    return fetch(`${options.url}/api/apm/sourcemaps`, {
      method: 'POST',
      headers: {
        'Content-Type': `multipart/form-data;boundary="${formData.getBoundary()}"`,
        'kbn-xsrf': 'true',
        'Authorization': `ApiKey ${options.token}`,
      },
      body: formData,
    }).then(function (response) {
      if (response.status >= 400) {
        throw new Error(response.statusText);
      }
      return response.json();
    });
  };

```

---

<div class="post-metadata">

**Author:** ![Alberto\_Delgado](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_delgado/32/98488_2.png) [@Alberto\_Delgado](https://discuss.elastic.co/u/Alberto_Delgado)\
**Post date:** [March 23, 2023, 3:11pm UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/5 "2023-03-23T15:11:30Z")

</div>

Hi @skumar7,

Apologies for the delay!

Seeing that you are using APM server 7.17 and also APM standalone server you can try these two things:

1. If you wanna keep uploading the sourcemaps to `/api/apm/sourcemaps`, make sure that you have configured the `kibana` section in your apm-server.yml. For instance:

```auto
apm-server.kibana.enabled: true
apm-server.kibana.host: "http://localhost:5601"
apm-server.kibana.username: "user"
apm-server.kibana.password: "pass"

```

and then upload them again.

1. If first option doesn't work, try to upload the sourcemaps to the APM server endpoint. More info here: [Source map upload API | APM User Guide [master] | Elastic](https://www.elastic.co/guide/en/apm/guide/master/sourcemap-api.html)

Cheers,  
Alberto

---

<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:** [April 20, 2023, 3:12pm UTC](https://discuss.elastic.co/t/sourcemaps-not-getting-applied/326923/6 "2023-04-20T15:12:09Z")

</div>

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