Unable to get RUM Agent working

Course: Elastic Observability
Version: 8.2.3
Question:

When attempting to follow section 3.4, I am unable to get the RUM agent to work properly, step 11 "You should see petclinic-react" appear in services, but it never appears.

I see the following errors in the petclinic-client container

GET /api/error 404 34.263 ms - 123
Sending error to Elastic APM { id: '14c1dc243e7810bf481592a973072460' }
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"
APM Server transport error (403): Unexpected APM Server response
Error: unauthorized: anonymous access not permitted for agent "nodejs"

So looking at fleet server APM Integration i notice the "nodejs" agent is not in the authorized anonymous access, so i add it

Still no luck.

Any ideas?

Hi @Eric-Domeier ,

you actually have two different agents based on JavaScript: one is the node agent for the backend and another is the RUM agent for the frontend. You are not required to change the settings in the APM integration, besides setting the secret token.

Can you please share the content of your config.js file for the petclinic-client container? Perhaps you have a misconfiguration over there.

Best,
Andre

Hi Andre,

Here is the current config

var config = {
  apm_server: process.env.ELASTIC_APM_SERVER_URL || 'http://fleet-server:8200',
  apm_server_token: process.env.ELASTIC_APM_SECRET_TOKEN || 'nonprodpwd',
  apm_server_js: process.env.ELASTIC_APM_SERVER_JS_URL || 'http://wxly.....pjpnh.labs.strigo.io:8200',
  apm_service_name: process.env.ELASTIC_APM_SERVICE_NAME || 'petclinic-node',
  apm_client_service_name: process.env.ELASTIC_APM_CLIENT_SERVICE_NAME || 'petclinic-react',
  apm_service_version: process.env.ELASTIC_APM_SERVICE_VERSION || '1.0.0',
  api_server: process.env.API_SERVER || 'http://petclinic-server:8000',
  api_prefix: process.env.API_PREFIX || '/petclinic/api',
  address_server: process.env.ADDRESS_SERVER || 'http://address-finder:5000',
  distributedTracingOrigins: process.env.DISTRIBUTED_TRACINGS_ORIGINS || 'http://petclinic-client:4000,http://petclinic-server:8000,http://localhost:4000,http://localhost:8080,http://localhost:8081'
}

module.exports = config;

I also tried it without the module.exports = config;

same result.

Is it just shortened here? Do you have the full URL setup in the config file?

Also, can you please share the result of running docker logs petclinic-client ?

Best,
Andre

Yes it's just shortened, I have the whole dynamic dns there

petclinic-client.logs

Have you included secretToken: settings.apm_server_token, to bin/www in the nodejs agent start for petclinic-client container?

It should be step 4 of Lab 3.3.

Best,
Andre

Current settings

#!/usr/bin/env node
const settings = require('../config')
var apm = require('elastic-apm-node').start({
  serviceName: settings.apm_service_name,
  serviceVersion: settings.apm_service_version,
  serverUrl: settings.apm_server,
  captureBody: "all",
  secretToken: settings.apm_server_token,
  errorOnAbortedRequests: true,
  captureErrorLogStackTraces: "always",
  sourceLinesErrorAppFrames: 10,
  sourceLinesErrorLibraryFrames: 10,
  sourceLinesSpanAppFrames: 10,
  sourceLinesSpanLibraryFrames: 10,
  transactionMaxSpans: -1,
  asyncHooks: false
})

That's interesting. This error looks like a problem in your nodejs agent configuration, but it looks ok. Do you see petclinic-node in the APM app?

Have you restarted petclinic-client container after setting the configurations?

Also test the RUM agent through Developer Tools Console in your browser.

Access Petclinic through http://<DYNAMIC_DNS>:4000 and check the Console in your Developer Tools. You should see something like this if it is working:

If it is not working please share the error that might appear in the Console.

Best,
Andre

Hi @Eric-Domeier ,

I reproduced your settings on a fresh environment and it looks like your problem is including nodejs to Allowed agents and Allowed services in the APM integration. See in the screenshot below how the Throughput column shows petclinic-react went down when I configured these settings, but got back again when I removed them:

Please remove these settings from you APM integration and save it. After this you should see petclinic-react in the APM app.

BTW, sometimes it might take a little bit to appear.

Best,
Andre

Hi @Andre_Murbach_Maidl

thanks that seems to have done the trick this time, very weird. I only added those because it wasn't working and was trying new things :slight_smile:

Cool! I'm glad it worked @Eric-Domeier.

Anything please let us know.

Best,
Andre

1 Like