elastic / elastic/apm-agent-nodejs

`_signalLambdaEnd` request to Lambda extension should set `Content-Type`

Open
#3,858 0 comments 0 reactions 0 assignees View on GitHub
agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

In a user support request it was noted that they saw this error in the Node.js APM agent logs running in a Lambda:

```
{ "log.level": "error", "@timestamp": "2024-01-17T20:54:32.917Z", "log.logger": "elastic-apm-node", "ecs.version": "8.10.0", "event.module": "apmclient", "durationMs": 53.83446400007233,
"err": "unexpected response status code: 400",
"message": "_signalLambdaEnd error" }
```

and the matching APM server logs included:

```
{
"http.request.body.bytes": 0,
"image": "docker.elastic.co/cloud-assets/apm:7.17.10-0",
"http.request.method": "POST",
"log.level": "error",
"http.response.status_code": 400,
"user_agent.original": "apm-agent-nodejs/3.50.0 ...",
"service.name": "apm-server",
"message": "data validation error",
"url.original": "/intake/v2/events?flushed=true",
"error.message": "invalid content type: ''",
// ...
}
```

(Side note: This seems to be a misconfigured Lambda that has the APM agent talking directly to APM server, instead of via the Elastic Lambda extension. IOW, this log.error is likely to be very rare.)

In any case, adding a `Content-Type: application/json`, even though the request is empty should avoid this rare error log.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.