How can I ensure that Elastic APM understands that an uploaded source map should be used for error monitoring?

I've tried to use source maps for making my errors readable and failed. The versions of my project and the source map are the same. The errors pile in in an unreadable format and my uploaded source maps are unused and unhappy. What does it take for the APM server to realise that it should use a source map?

Shell script for uploading source map manually

#!/bin/bash

# Find the main file with the latest version
main_file=$(ls -t ./build/static/js/main.*.js | head -1)
map_file=$(ls -t ./build/static/js/main.*.js.map | head -1)

echo "Uploading sourcemap for $main_file and $map_file"

curl -X POST "https://**aha**/api/apm/sourcemaps" \
-H 'Content-Type: multipart/form-data' \
-H 'kbn-xsrf: true' \
-F 'service_name=**aha**' \
-F 'service_version=gekkigheid' \
-F "bundle_filepath=static/js/bundle.js" \
-F "sourcemap=@$map_file"

Config for APM RUM agent

import { init as initApm } from "@elastic/apm-rum";
import env from "./env";

const setupApm = () => {
  initApm({
    // Set required service name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
    serviceName: "**aha**",

    // Set custom APM Server URL (default: http://localhost:8200)
    serverUrl: "http://**aha**:8200",

    // Set service version (required for sourcemap feature)
    serviceVersion: "gekkigheid",

    environment: env.APM_ENVIRONMENT ?? "development",
  });
};

export default setupApm;

Hi @Casper_Aangeenbrug,

Thanks for reaching out!

I have a few questions and comments:

  • What version of RUM are you using? (version 5.12 added this fix for error capturing)

  • What version of the elastic stack are you using?

  • Are you using APM server standalone or APM integration?

  • here is an full-fledge example of how to make work sourcemaps for APM standalone with version 7.17, please take a look when you have time.

  • Important: For higher versions the steps remain the same, the only difference is to make sure they upload the maps to the correct endpoint.

  • if you are using APM standalone server you should be uploading sourcemaps to APM server (e.g. http://localhost:8200/assets/v1/sourcemaps, in case you are using 7.17), if you are using integration you should be uploading sourcemaps to Kibana (e.g. http://localhost:5601/api/apm/sourcemaps)

Additionally, since I don't know the stack version you are using, I would also like to link the existing bugs related to sourcemaps we had in particular versions of APM.

Cheers,
Alberto

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