AWS Lambda Logs (Go)
Overview
This guide explains how to enable application and platform logs for a Go (Golang) AWS Lambda function using the OpenTelemetry Collector Lambda Layer, and export them to KubeSense Logs.
What this collects: This setup collects Lambda platform logs and function logs via the Lambda Telemetry API receiver (telemetryapi).
1) Add the OpenTelemetry Collector Lambda Layer
Add the OpenTelemetry Collector Lambda Layer to your Lambda function.
arn:aws:lambda:<region>:184161586896:layer:opentelemetry-collector-<amd64|arm64>-0_19_0:1Example (x86_64, us-east-1):
arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-collector-amd64-0_19_0:1Choose the correct:
- Region
- Architecture (
amd64orarm64)
2) Set Lambda environment variables (logs-only)
Set these environment variables in your Lambda configuration:
AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrument
OPENTELEMETRY_COLLECTOR_CONFIG_URI=/var/task/collector.yaml
OTEL_SERVICE_NAME=<SERVICE_NAME>OTEL_SERVICE_NAMEshould reflect your application/service name (for example:payments-lambda).
3) Add collector.yaml (logs pipeline only)
Place a collector.yaml file in the Lambda root directory and include it in your deployment package.
receivers:
telemetryapi:
types: ["platform", "function"]
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"
processors:
batch:
resource:
attributes:
- action: insert
key: kubesense.cluster
value: <CLUSTER_NAME> # Provided by KubeSense team (e.g., Kreditbee)
- action: insert
key: kubesense.env_type
value: legacy
exporters:
otlphttp/kubesense-logs:
endpoint: "http://<KUBESENSE_LOG_BACKEND_HOST>:30055" # KubeSense Logs endpoint
tls:
insecure: true
debug:
verbosity: detailed
service:
pipelines:
logs:
receivers: [telemetryapi]
processors: [resource, batch]
exporters: [otlphttp/kubesense-logs]Fill in placeholders: Replace <CLUSTER_NAME> and <KUBESENSE_LOG_BACKEND_HOST> with the values provided by the KubeSense team.
4) Deploy and confirm
Confirm these are in place:
- OpenTelemetry Collector Lambda Layer attached
- Required environment variables set
collector.yamlincluded in the Lambda deployment package
Then invoke your Lambda and verify logs appear in KubeSense.
Reference
For official OpenTelemetry Lambda Collector releases and documentation, see: https://github.com/open-telemetry/opentelemetry-lambda/releases