Skip to content

Commit 411891c

Browse files
authored
Update docs (#87)
1 parent 2980ed0 commit 411891c

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

docs/aws-lambda-extension.asciidoc

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[[aws-lambda-extension]]
22
= AWS Lambda Extension (Experimental)
33

4+
experimental::[]
5+
46
Elastic's APM Agents instrument AWS Lambda functions via an AWS Lambda Extension.
57

8+
[discrete]
69
[[aws-lambda-arch]]
710
== Extension Architecture
811

@@ -12,6 +15,8 @@ image:images/data-flow.png[image showing data flow from lambda function, to exte
1215

1316
By using a custom-built AWS Lambda Extension, Elastic APM Agents can send data to a locally running Lambda Extension process, and that process will forward data on to APM Server. The Lambda Extension ensures that any latency between the Lambda function and the AWS Server instance will not cause latency in the Lambda function/Service itself.
1417

18+
[discrete]
19+
[[aws-lambda-instrumenting]]
1520
== Instrumenting a Lambda Function
1621

1722
The rest of this guide contains instructions for instrumenting a Lambda function. There are two high level steps to instrumenting an AWS Lambda function.
@@ -21,6 +26,7 @@ The rest of this guide contains instructions for instrumenting a Lambda function
2126

2227
We'll start with installing the Lambda extension.
2328

29+
[discrete]
2430
[[aws-lambda-install]]
2531
== Installing the Lambda Extension
2632

@@ -63,6 +69,8 @@ The `elastic-lambda.js` command assumes you have a `install.yaml` file configure
6369
./elastic-lambda.js install
6470
----
6571

72+
[discrete]
73+
[[aws-lambda-configuring]]
6674
== Configuring the Installer
6775

6876
A fully configured `install.yaml` might look like the following
@@ -83,47 +91,68 @@ install:
8391

8492
The meaning of each `install.yaml` configuration field is as follows.
8593

94+
[discrete]
95+
[[aws-lambda-layer_name]]
8696
=== `layer_name`
8797

8898
This is the name the compiler will use for your AWS Layer. The default, `apm-lambda-extension`, should work for most scenarios.
8999

100+
[discrete]
101+
[[aws-lambda-function_name]]
90102
=== `function_name`
91103

92104
The name of your Lambda function. The installer will use this to configure the correct Lambda function. This must be the name of a function that already exists.
93105

106+
[discrete]
107+
[[aws-lambda-lambda_env]]
94108
=== `lambda_env`
95109

96110
The installer will use the key/value pairs in this section of the configuration file to add environment variables to your Lambda function. The provided variables are those required to make the extension work correctly.
97111

112+
[discrete]
113+
[[aws-lambda-log_level]]
98114
==== `ELASTIC_APM_LOG_LEVEL`
99115

100116
The log level for the APM Agent. Consult your https://www.elastic.co/guide/en/apm/agent/index.html[APM Agent's documentation] for more information.
101117

118+
[discrete]
119+
[[aws-lambda-secret_token]]
102120
==== `ELASTIC_APM_SECRET_TOKEN`
103121

104122
The APM secret token. The extension will use this when communicating with APM Server.
105123

124+
[discrete]
125+
[[aws-lambda-api_key]]
106126
==== `ELASTIC_APM_API_KEY`
107127

108128
An alternative authentication method to the secret token. The extension will use this when communicating with APM Server.
109129

130+
[discrete]
131+
[[aws-lambda-server_url]]
110132
==== `ELASTIC_APM_SERVER_URL`
111133

112134
Your APM Server URL. This is the final destination for your data.
113135

136+
[discrete]
137+
[[aws-lambda-service_name]]
114138
==== `ELASTIC_APM_SERVICE_NAME`
115139

116140
The configured name of your application or service. The APM Agent will use this value when reporting data to APM Server.
117141
If unset, the APM Agent will automatically set the value based on `AWS_LAMBDA_FUNCTION_NAME` or `context.functionName`.
118142

143+
[discrete]
144+
[[aws-lambda-timeout_seconds]]
119145
==== `ELASTIC_APM_DATA_RECEIVER_TIMEOUT_SECONDS`
120146

121147
The timeout value, in seconds, for the Lambda Extension's server.
122148

149+
[discrete]
150+
[[aws-lambda-handler]]
123151
== Configuring the Agent and Lambda Function handler
124152

125153
Once you've installed the extension, there's one last step to take. You'll need to wrap the Lambda function handler.
126154

155+
[discrete]
127156
[[aws-lambda-nodejs]]
128157
=== Node.js
129158

@@ -141,6 +170,7 @@ exports.handler = apm.lambda(async function handler (event, context) {
141170
})
142171
----
143172

173+
[discrete]
144174
[[aws-lambda-python]]
145175
=== Python
146176

@@ -154,6 +184,8 @@ def handler(event, context):
154184
return {"statusCode": r.status_code, "body": "Success!"}
155185
----
156186

187+
[discrete]
188+
[[aws-lambda-manual-instrumentation]]
157189
== Manual Installation
158190

159191
It's possible to install and configure the extension manually. In order to do so, you'll need to
@@ -163,22 +195,28 @@ It's possible to install and configure the extension manually. In order to do s
163195
3. Configure your function to use that layer
164196
4. Configure your function's environment variables correctly
165197

198+
[discrete]
199+
[[aws-lambda-download-released]]
166200
=== Download a Released Extension
167201

168202
The extension is released as a ZIP archive via https://github.com/elastic/apm-aws-lambda/releases[the GitHub releases page]. To download an archive, simply navigate to the latest version, and choose either the AMD64 or ARM64 release (depending on which architecture your Lambda function uses).
169203

170204
image:images/assets.png[image of assets tab in releases]
171205

206+
[discrete]
207+
[[aws-lambda-publish-layer]]
172208
=== Publish a Lambda layer
173209

174210
Next, you'll want to take that release ZIP file and publish it https://docs.aws.amazon.com/lambda/latest/dg/invocation-layers.html?icmpid=docs_lambda_help[as a Lambda layer]. A Lambda layer is a zip file archive that contains additional code or files for your Lambda function.
175211

176-
To do this, navigate the the Layers section of the AWS console, click the _Create layer_ button, and follow the prompts to upload the ZIP archive as a layer.
212+
To do this, navigate to the Layers section of the AWS console, click the _Create layer_ button, and follow the prompts to upload the ZIP archive as a layer.
177213

178214
image:images/layers.png[image of layers section in the Amazon Console]
179215

180216
After publishing a layer, you'll receive a Version ARN. This ARN is the layer's unique identifier.
181217

218+
[discrete]
219+
[[aws-lambda-configure-layer]]
182220
=== Configure the Layer
183221

184222
Once you've published a layer, you'll need to configure your function to use that layer. To add a layer
@@ -189,6 +227,8 @@ Once you've published a layer, you'll need to configure your function to use tha
189227
4. Enter the Version ARN of your layer in the _Specify an ARN_ text input
190228
5. Click the _Add_ button
191229

230+
[discrete]
231+
[[aws-lambda-configure-env]]
192232
=== Configure your Environment Variables
193233

194234
Finally, once the layer's in place you'll need to configure a few environmental variables. To configure variables
@@ -198,25 +238,36 @@ Finally, once the layer's in place you'll need to configure a few environmental
198238
3. Click on _Environment variables_
199239
4. Add the necessary variables.
200240

241+
[discrete]
242+
[[aws-lambda-variables]]
201243
=== The Necessary Variables
202244

245+
[discrete]
246+
[[aws-lambda-central_config]]
203247
==== `ELASTIC_APM_CENTRAL_CONFIG`
204248

205249
The `ELASTIC_APM_CENTRAL_CONFIG` value _must_ be set to `false`. Central configuration does not work in a Lambda environment, and having this on will negatively impact the performance of your Lambda function.
206250

251+
[discrete]
252+
[[aws-lambda-cloud_provider]]
207253
==== `ELASTIC_APM_CLOUD_PROVIDER`
208254

209255
The `ELASTIC_APM_CLOUD_PROVIDER` value _must_ be set to `none`. Amazon's Cloud Metadata APIs are not available in an AWS Lambda environment, and attempting to fetch this data will negatively impact the performance of your Lambda function.
210256

257+
[discrete]
258+
[[aws-lambda-lambda_apm_server]]
211259
==== `ELASTIC_APM_LAMBDA_APM_SERVER`
212260

213261
The `ELASTIC_APM_LAMBDA_APM_SERVER` controls where the Lambda extension will ship data. This should be the URL of the final APM Server destination for your telemetry.
214262

263+
[discrete]
264+
[[aws-lambda-apm_secret_token]]
215265
==== `ELASTIC_APM_SECRET_TOKEN` or `ELASTIC_APM_API_KEY`
216266

217-
Either `ELASTIC_APM_API_KEY` or `ELASTIC_APM_SECRET_TOKEN` needs to be set. This controls the authentication method that extension uses when sending data to the URL configured via `ELASTIC_APM_LAMBDA_APM_SERVER`.
267+
Either `ELASTIC_APM_API_KEY` or `ELASTIC_APM_SECRET_TOKEN` needs to be set. This controls the authentication method that the extension uses when sending data to the URL configured via `ELASTIC_APM_LAMBDA_APM_SERVER`.
218268

269+
[discrete]
270+
[[aws-lambda-apm_server_url]]
219271
==== `ELASTIC_APM_SERVER_URL`
220272

221273
This _must_ be configured to the value `http://localhost:8200`. This configuration field controls where your APM Agent sends data. The extension listens for data on `localhost:8200`.
222-

0 commit comments

Comments
 (0)