# How to add api gateway api key to lambda APM?

**URL:** https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854
**Category:** APM
**Tags:** nodejs, aws-lambda
**Created:** [November 1, 2022, 2:10am UTC](https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854 "2022-11-01T02:10:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alex\_123123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_123123/32/97753_2.png) [@alex\_123123](https://discuss.elastic.co/u/alex_123123)
#### Post date: [November 1, 2022, 2:10am UTC](https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854/1 "2022-11-01T02:10:32Z")

</div>

**Kibana version** : 8.4.1

**Elasticsearch version** : 8.4.1

**APM Server version** : 8.4.1

**APM Agent language and version** : nodejs, elastic-apm-extension-ver-1-1-0-x86\_64, elastic-apm-node-ver-3-38-0

**Browser version** : /

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: lambda layers

**Fresh install or upgraded from other version?**

**Is there anything special in your setup?**

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**: There is an AWS Api-gateway with API key placed between lambda and APM server. Is there any ways to add custom header (E.G. api-gateway key) on APM agent? So that every APM agent's request towards APM server will contain api-gateway key in the header.

**Errors in browser console (if relevant)**: 403 return code from api-gateway

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

### Author: ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)
#### Post date: [November 1, 2022, 5:05pm UTC](https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854/2 "2022-11-01T17:05:40Z")

</div>

Hello @alex_123123,

In Elastic's APM lambda architecture, the APM agent (Node.js in this case) talks to the local APM extension, which then talks to the APM server.

If I understand your setup correctly, you'd need a way to tell the APM extension to add `x-api-key: $configuredValue` to all requests to APM server. The Node.js APM agent does not expose a configuration option to set headers for requests to APM server. @lahsivjar Do you know if the Lambda Extension has any such configuration? My guess is that it does not.

@alex_123123 If that is the case, then the next best step is to add a feature request to the Elastic APM Lambda extension repo: [Issues · elastic/apm-aws-lambda · GitHub](https://github.com/elastic/apm-aws-lambda/issues)

---

<div class="post-metadata">

### Author: ![lahsivjar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lahsivjar/32/101451_2.png) [@lahsivjar](https://discuss.elastic.co/u/lahsivjar)
#### Post date: [November 2, 2022, 2:44am UTC](https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854/3 "2022-11-02T02:44:50Z")

</div>

> @lahsivjar Do you know if the Lambda Extension has any such configuration? My guess is that it does not.

Thanks for the answer. You are correct, there is no such configuration in the lambda extension at the moment.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 22, 2022, 10:45pm UTC](https://discuss.elastic.co/t/how-to-add-api-gateway-api-key-to-lambda-apm/317854/4 "2022-11-22T22:45:40Z")

</div>

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