ObserveNow
...
Cloud Providers
Amazon Web Services (AWS)
AWS Lambda Functions
overview this document outlines the process of automatically instrumenting aws lambda functions using opentelemetry (otel) layers it details the necessary steps for adding lambda layers, configuring environment variables, and integrating the opentelemetry collector for effective observability this integration works for metrics and traces since opentelemetry logs support is unstable for most languages, we recommend using the cloudwatch exporter for bringing aws lambda logs into observenow supported languages opentelemetry provides auto instrumentation support for the following aws lambda runtimes java, javascript, python, ruby steps for instrumentation step 1 add the otel collector lambda layer before instrumenting your application, you must add the opentelemetry collector lambda layer follow these steps open the aws management console navigate to the lambda function you intend to instrument in the layers section of the designer, click add a layer under specify an arn , enter the arn for the otel collector lambda layer, ensuring to replace \<region> with the appropriate aws region for your lambda function find the most recent collector layer release here make sure to use the layer in the same region as your lambda functions the community publishes layers in all available regions example arn\ aws\ lambda \<region> 184161586896\ layer\ opentelemetry collector amd64 0 11 0 1 note ensure that the layers are deployed in the same aws region as your lambda function, as lambda layers are region specific resources step 2\ add the instrumentation lambda layer add the instrumentation layer corresponding to your selected programming language by following the same steps as above for python example arn\ aws\ lambda 184161586896\ layer\ opentelemetry python 0 10 0 1 find the most recent instrumentation layer release for your language and use it’s arn after changing the \<region> tag to the region your lambda note ensure that the layers are deployed in the same aws region as your lambda function, as lambda layers are region specific resources step 3 configure environment variables adjust the entry point of your application by configuring the aws lambda exec wrapper environment variable according to your programming language for node js, java, or ruby aws lambda exec wrapper=/opt/otel handler for python aws lambda exec wrapper=/opt/otel instrument create an environment variable to specify the configuration file for the opentelemetry collector opentelemetry collector config file=/var/task/collector yaml step 4 configure the opentelemetry collector the configuration of the otel collector lambda layer follows the opentelemetry standard by default, the otel collector lambda layer uses the config yaml since we want to use a customization, create a collector yaml file in the root directory receivers otlp protocols grpc endpoint 0 0 0 0 4317 http endpoint 0 0 0 0 4318 exporters otlphttp endpoint "https //\<opsverse otel endpoint>/" headers authorization "basic base64{\<username> \<password>}" retry on failure max elapsed time 600s prometheusremotewrite endpoint "https //\<opsverse metrics endpoint>/api/v1/write" headers authorization "basic base64{\<username> \<password>}" resource to telemetry conversion enabled true retry on failure max elapsed time 600s service pipelines traces receivers \[otlp] exporters \[otlphttp] metrics receivers \[otlp] exporters \[prometheusremotewrite] step 5 view the metrics in observenow metrics collected from lamda function can be viewed under the explore section of observenow grafana step 6 view the traces in observenow traces collected from lamda function can be viewed under the explore section of observenow grafana