Using APM NodeJS in a NestJS enviroment - Can't initialize agent

I'm trying to autenticate ELK using the NodeJS agent in a NestJS environment. I followed the Express tutorial to use the NodeJS agent.

On the application bootstrap, I'm getting this errors:

{"log.level":"error","@timestamp":"2022-11-10T22:15:10.552Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"APM Server transport error (400): Unexpected APM Server response\n{\"error\":{\"root_cause\":[{\"type\":\"mapper_parsing_exception\",\"reason\":\"failed to parse\"}],\"type\":\"mapper_parsing_exception\",\"reason\":\"failed to parse\",\"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"Malformed content, found extra data after parsing: START_OBJECT\"}},\"status\":400}"}


{"log.level":"trace","@timestamp":"2022-11-10T22:15:10.552Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"3be13b70d60c929068f15d8cc99729aa","concluded":false,"ecs":{"version":"1.6.0"},"error":{"type":"Error","message":"Unexpected APM Server response","stack_trace":"Error: Unexpected APM Server response\n    at processIntakeErrorResponse (/PROJECT_DIR/node_modules/elastic-apm-http-client/index.js:1489:15)\n    at IncomingMessage.<anonymous> (/PROJECT_DIR/node_modules/elastic-apm-http-client/index.js:1044:17)\n    at IncomingMessage.emit (events.js:412:35)\n    at endReadableNT (internal/streams/readable.js:1334:12)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)"},"message":"completePart intakeRes"}

My stack versions:
"@nestjs/common": "^7.6.18",
"@nestjs/core": "^7.6.18",
"@nestjs/jwt": "^7.2.0",
"@nestjs/mongoose": "^7.2.4",
"@nestjs/passport": "^7.1.6",
"@nestjs/platform-express": "^7.6.18"
(...)
"elastic-apm-node": "^3.40.0",

Elastic/Kibana version: v7.16.2

@Daniel_K welcome to the forum!

The first error message includes a response that is coming from Elasticsearch. Have you configured the Node.js agent to connect to Elasticsearch? You need to connect it to Elastic APM Server.

I'm starting using ELK, and I didn't know APM was a separate service running in a different port.

After this, I got a error in TLS communication, but I found answers searching at google.

Communication agent => APM service is working now. Thanks for the help!

1 Like

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