[Workshop Alert] Dynamic Scoring for WAF Actions and CloudFront Traffic - Save Your Seat Now!

Connecting OpenTelemetry to AWS Fargate

  • Coralogix
  • February 7, 2023
Share article

OpenTelemetry is an open-source observability framework that provides a vendor-neutral and language-agnostic way to collect and analyze telemetry data. This tutorial will show you how to integrate OpenTelemetry with Amazon AWS observability Fargate, a container orchestration service that allows you to run and scale containerized applications without managing the underlying infrastructure.

Prerequisites:

  • You should have a basic understanding of OpenTelemetry and Amazon AWS Fargate
  • You should have an AWS account, and the AWS CLI installed and configured on your local machine
  • You should have a containerized application that you want to instrument with OpenTelemetry and run on Fargate

Step 1: Create an Amazon Elastic Container Registry (ECR) repository

The first step is to create an ECR repository where you will push your containerized application. You can do this by running the following command:

aws ecr create-repository --repository-name <your_repository_name>

Step 2: Build and Push Your Containerized Application

Build your containerized application using your preferred containerization tool and then push it to the ECR repository you created in step 1.

# Build the container
docker build -t <your_image_name> .
# Tag the container
docker tag <your_image_name> <your_account_id>.dkr.ecr.<your_region>.amazonaws.com/<your_repository_name>:<your_tag>
# Push the container to ECR
docker push <your_account_id>.dkr.ecr.<your_region>.amazonaws.com/<your_repository_name>:<your_tag>

Step 3: Install the OpenTelemetry Collector as a Sidecar

The OpenTelemetry Collector is a daemon that can collect and process telemetry data from your applications. To install the collector as a sidecar container in your Fargate task, you will need to create a new task definition that includes both your application container and the collector container.

# Create a new task definition
aws ecs register-task-definition --family <your_task_definition_name> --container-definitions "[{\"name\":\"<your_application_name>\",\"image\":\"<your_account_id>.dkr.ecr.<your_region>.amazonaws.com/<your_repository_name>:<your_tag>\"},{\"name\":\"otel-collector\",\"image\":\"open-telemetry/opentelemetry-collector\",\"environment\":[{\"name\":\"OTEL_EXPORTER_OTLP_ENDPOINT\",\"value\":\"<your_otel_exporter_endpoint>\"}]\"}]"

Step 4: Create a new Fargate Cluster

Now that you have a task definition, you can create a new Fargate cluster and start a task using that definition.

aws ecs create-cluster --cluster-name <your_cluster_name>
aws ecs run-task --cluster <your_cluster_name> --task-definition <your_task_definition_name>

Step 5: View the Telemetry Data

Once the task runs, you can view the telemetry data collected by the OpenTelemetry collector by sending a request to the location where you have exported your OpenTelemetry data. 

Remember: Coralogix offers a complete integration with Open Telemetry, for logs, traces, and metrics!

Serverless Observability is the next big challenge

As Serverless architectures grow, so will the observability challenge. By combining tools that solve the cross-cutting observability problem, like OpenTelemetry, and Fargate, we bring ourselves one step closer to an efficient, efficient, battle-tested, and production-ready observability solution for the serverless world. 

Observability and Security
that Scale with You.