Deploying the Edge Delta Lambda Extension
6 minute read
Overview
Edge Delta’s AWS Lambda Extension is deployed as a layer within your Lambda Function. See Serverless AWS Monitoring. It is published in the AWS Serverless Application Repository and there are layers for ARM64 or AMD64. The Lambda extension is run on AWS as a part of the lambda execution and lambda function logs are sent to the extension. The extension in turn sends logs to an Edge Delta Hosted Agent.
To configure Lambda monitoring using the Lambda Extension:
- Create an Agent Configuration.
- Create an Edge Delta Hosted Agent.
- Deploy the Lambda extension.
- Specify the hosted agents endpoint.
- Configure other environment variables as needed.
Create an Agent Configuration
Create an agent configuration that the hosted agent will use to ingest logs sent from lambda extension, identify function resources, and populate lambda tags.
- Click Pipelines - Legacy Pipelines.
- Click Create Configuration.
- Click Continue.
- Select Helm and click Continue.
- Specify a name for the hosted agent configuration and click Create Configuration.
- Add a File Input with the following path:
/var/captured_requests/body_*.json
- Connect the File Input to a Parse JSON Attributes node.
- Configure the Parse JSON Attributes node with the process_field
item.body
. - Connect Parse JSON Attributes to an Extract JSON Field node.
- Configure Extract JSON Field to extract the whole
message
field path to assign to the body, and setkeep_log_if_failed: true
. - Connect Extract JSON Field to a Log Transform node.
- Configure the Log Transform node to delete
attributes.message
(they are in body). Also deleteattributes.timestamp
. - Click Pipelines - Legacy Pipelines.
- Click the Actions column for the new agent row you just created and select Edit.
- Add the following agent settings:
settings:
multiline_max_byte_size: 11MB
max_incomplete_line_buffer_size: 10MB
These values should match the max of lambda/cloudwatch so there are no OOM issues.
v3 Configuration Example
version: v3
settings:
tag: <configuration name>
log:
level: debug
archive_flush_interval: 5m0s
archive_max_byte_limit: 10MB
multiline_max_byte_size: 11MB
max_incomplete_line_buffer_size: 10MB
links:
- from: file_input_lambda_logs
to: parse_json_attributes
- from: ed_component_health
to: ed_health
- from: ed_node_health
to: ed_health
- from: parse_json_attributes
to: extract_json_field
- from: parse_json_attributes
path: failure
to: extract_json_field
- from: log_transform
to: ed_archive_output
- from: extract_json_field
to: log_transform
- from: extract_json_field
path: failure
to: log_transform
nodes:
- name: file_input_lambda_logs
type: file_input
path: /var/captured_requests/body_*.json
- name: ed_component_health
type: ed_component_health_input
- name: ed_agent_stats
type: ed_agent_stats_input
- name: ed_node_health
type: ed_node_health_input
- name: ed_pipeline_io_stats
type: ed_pipeline_io_stats_input
- name: ed_health
type: ed_health_output
- name: ed_archive_output
type: ed_archive_output
- name: parse_json_attributes
type: parse_json_attributes
process_field: item.body
- name: log_transform
type: log_transform
transformations:
- field_path: attributes.message
operation: delete
- field_path: attributes.timestamp
operation: delete
- name: extract_json_field
type: extract_json_field
field_path: message
keep_log_if_failed: true
Create an Edge Delta Hosted Agent
Create a new Edge Delta Hosted agent. Select the configuration you created and select the HTTPS endpoint option.
- Click Pipelines in the Edge Delta Web App and select Hosted Agents.
- Click + Create.
- Enter a descriptive name for the hosted agent.
- Select an agent version. The interface lists the current stable version (the lower version number) and most recent candidate version (the higher version number). Choose the current stable version. If this configuration doesn’t work you can contact Edge Delta support to experiment with the candidate.
- Select a public cloud provider. If your preferred cloud provider is not listed, contact Edge Delta support.
- Select the region where the hosted agent will be hosted.
- For Config ID, there are 2 options:
- select Generate one for me if you want to create a new agent configuration.
Note: this will generate an agent with a v2 configuration.
- If you have already configured an agent and you want to reuse that configuration, select the configuration ID from the drop down.
Note: Specify a v3 configuration if you want to configure the hosted agent using Visual Pipelines.
- Select the HTTPS checkbox if you want your data source to push data to a secure HTTP endpoint on the hosted agent.
- Click Create.
Copy the HTTPS endpoint generated for the agent from the Hosted Agents table.
Deploying the Lambda Extension
Get the ARN from the AWS Serverless Application Repository
- Open AWS Serverless Application Repository and click Available Applications.
- Search for EdgeDelta and select the extension (either ARM64 or AMD64).
- Confirm the layer template such as the application name and click Deploy.
The extension can be deployed multiple times if necessary by providing different names. Deploying with an existing application name upgrades the existing deployment if an upgrade is available.
- On AWS Lambda, expand Additional Resources and click Layers.
- Click the Layer you just created (
edgedelta-lambda-extension-arm64
oredgedelta-lambda-extension-amd64
) - Copy the ARN of the Lambda Layer.
Add the Layer to your Lambda Function
Add the layer to your Lambda Function using the CLI or using the Console.
CLI:
Replace <Function Name>
and <ARN>
aws lambda update-function-configuration -function-name <Function Name> \
--layers “<ARN>"
Console
- Navigate to the Lambda Function you want to monitor.
- In the Layers section, click Add a Layer.
- Click Specify an ARN, paste the ARN you copied earlier and click Verify.
- Click Add.
Specify the Endpoint Environment Variable
To configure Environment Variables for the Lambda function:
- Open the Functions page of the Lambda console.
- Choose a function.
- Choose Configuration, then choose Environment variables.
- Under Environment variables, choose Edit.
- Choose Add environment variable.
- Enter a key and value.
Push Destination Variables
Configure the Pusher Mode as http and specify the hosted agent endpoint URL you copied earlier.
PUSHER_MODE:
Usehttp
for hosted environments (default).ED_ENDPOINT:
Specify the Edge Delta Hosted Agent endpoint.
Configuration Variables
Configure any other environment variables you need:
ED_FORWARD_LAMBDA_TAGS
: If set totrue
, logs are enriched with lambda tags (in the field “lambda_tags”). Lambda function role needs to have thelambda:ListTags
permission.ED_LAMBDA_LOG_TYPES
: The variable defines which types of logs you want to get from the Lambda Function. Options arefunction,platform,extension
. Default isfunction,platform
.ED_PUSH_TIMEOUT_SEC
: Push timeout is the duration between sending batches of logs (in seconds). The default is 5.ED_RETRY_INTERVAL_MS
: The initial interval to wait until the next retry (in milliseconds). It is increased exponentially until the Edge Delta process is shut down. The default is 100.ED_BUFFER_SIZE_MB
: Maximum buffer size to keep logs (in MB). The default is 20. Some logs may be dropped if the buffer exceeds this limit.ED_FLUSH_AT_NEXT_INVOKE
: If set totrue
, logs are flushed at the start of the next invocation of the function. Normally, logs are flushed after the function execution finishes, which can add to the total running time. For lambda functions that are executed periodically,ED_FLUSH_AT_NEXT_INVOKE
can be turned on to reduce costs.ED_PRINT_EXTENSION_LOGS
: If set totrue
, the extension’s own logs are sent to CloudWatch.
Lambda can buffer logs and deliver them to the subscriber. You can configure this behavior in the subscription request by specifying the following optional fields:
ED_LAMBDA_MAX_ITEMS
: The maximum number of events to buffer in memory. Default: 1000. Minimum: 1000. Maximum: 10000. This is also the size of the channel that the Edge Delta http server writes into and which inputs consume.ED_LAMBDA_MAX_BYTES
: The maximum size (in bytes) of the logs to buffer in memory. Default: 262144. Minimum: 262144. Maximum: 1048576.ED_LAMBDA_TIMEOUT_MS
: The maximum time (in milliseconds) to buffer a batch. Default: 1000. Minimum: 25. Maximum: 30000.