APM for AWS Lambda 'APM Server transport error (ECONNREFUSED)'

(Marcin Druzgała) #1

Kibana version: v6.6.0

Elasticsearch version:v6.6.0

APM Server version:v6.6.0

APM Agent language and version: "elastic-apm-node": "2.5.1"

So I have followed the steps described on the APM site to set APM plugin in my AWS lambda function: https://www.elastic.co/guide/en/apm/agent/nodejs/1.x/lambda.html

Then I've copied the config from APM configuration site on Kibana (APM -> Setup instructions) but it doesn't work.

Here is the code:

import apm from 'elastic-apm-node/start'

const agent = apm.start({
  serviceName: 'test-api',
  secretToken: 'secret_value',
  serverUrl: 'https://hash.apm.eu-west-1.aws.cloud.es.io:443',
  logLevel: 'debug'

Then wrapped my function like that:

export const testFunction = agent.lambda(async (event: APIGatewayEvent) => {});

When I run the lambda and hit the endpoint related to this function I can see log in Cloudwatch that says:

"APM Server transport error (ECONNREFUSED): connect ECONNREFUSED" So it looks like it's trying to connect to localhost instead of connecting with remote server?

I've tried the .NET Core APM as well and it's not throwing any error but it's not sending anything as well so what am I doing wrong?

(Stephen Belanger) #2

You need to use elastic-apm-node, not elastic-apm-node/start. The start script calls the start method internally, and assumes your settings have been set using environment variables or a separate config file. Your code is effectively calling start twice. The first call doesn't have the serverUrl set, so it assumes localhost.

Also, the promise format isn't supported yet. We're working on it. Lambda support is still experimental.

(system) closed #3

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