From 0fd7cfa167530a36ac955ac068686f93947d47c1 Mon Sep 17 00:00:00 2001 From: bardabun Date: Wed, 20 Nov 2024 10:30:19 +0200 Subject: [PATCH] added log group creation instructions --- docs/shipping/Code/java.md | 45 +++++++++++++++++++++-------------- docs/shipping/Code/node-js.md | 35 +++++++++++++++++---------- docs/shipping/Code/python.md | 43 ++++++++++++++++++++------------- 3 files changed, 75 insertions(+), 48 deletions(-) diff --git a/docs/shipping/Code/java.md b/docs/shipping/Code/java.md index 0efdc699..16fb5de7 100644 --- a/docs/shipping/Code/java.md +++ b/docs/shipping/Code/java.md @@ -1158,7 +1158,7 @@ Give your traces time to process, after which they'll be available in your [Trac This guide provides an overview of deploying your Java application on Amazon ECS, using OpenTelemetry to collect and send tracing data to Logz.io. It offers a step-by-step process for setting up OpenTelemetry instrumentation and deploying both the application and OpenTelemetry Collector sidecar in an ECS environment. -#### **Prerequisites** +#### Prerequisites Before you begin, ensure you have the following prerequisites in place: @@ -1173,7 +1173,7 @@ Before you begin, ensure you have the following prerequisites in place: For a complete example, refer to [this repo](https://github.com/logzio/opentelemetry-examples/tree/main/java/traces/ecs-service). ::: -#### **Architecture Overview** +#### Architecture Overview The deployment will involve two main components: @@ -1200,7 +1200,7 @@ project-root/ └── Dockerfile # Dockerfile for the Collector ``` -#### **Steps to Deploy the Application** +#### Steps to Deploy the Application 1. Project Structure Setup @@ -1233,17 +1233,17 @@ Add the following dependencies in your `pom.xml` (or equivalent Gradle build fil Include the Java agent when running your application to enable tracing. see here for more details: https://opentelemetry.io/docs/zero-code/java/agent/getting-started/ -#### **Integrating OpenTelemetry Java Agent** +#### Integrating OpenTelemetry Java Agent -1. **Download the OpenTelemetry Java Agent** +1. Download the OpenTelemetry Java Agent Get the latest version of `opentelemetry-javaagent.jar` from the [OpenTelemetry Java Agent GitHub releases](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases). -2. **Add the Agent to Your Application** +2. Add the Agent to Your Application Place the `opentelemetry-javaagent.jar` in your project as mentioned in the atchitectre structure above. -3. **Modify the Application's Startup Command** +3. Modify the Application's Startup Command Include the `-javaagent` flag when starting your Java application to load the OpenTelemetry agent: @@ -1251,7 +1251,7 @@ see here for more details: https://opentelemetry.io/docs/zero-code/java/agent/ge java -javaagent:/path/to/opentelemetry-javaagent.jar -jar your-app.jar ``` -4. **Set Environment Variables for OpenTelemetry** +4. Set Environment Variables for OpenTelemetry Use environment variables to configure the agent, such as the OTLP endpoint and resource attributes: @@ -1261,11 +1261,11 @@ see here for more details: https://opentelemetry.io/docs/zero-code/java/agent/ge export OTEL_RESOURCE_ATTRIBUTES="service.name=java-app" ``` -#### **Dockerize Your Application** +#### Dockerize Your Application Create a Dockerfile to build a Docker image of your Java application. Below is the essential Dockerfile to get started: -#### **Dockerfile** +#### Dockerfile ```dockerfile # Use a Maven image to build the application @@ -1304,15 +1304,15 @@ ENTRYPOINT ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "app. ``` -#### **Configure the OpenTelemetry Collector** +#### Configure the OpenTelemetry Collector The OpenTelemetry Collector receives traces from the application and exports them to Logz.io. Create a `collector-config.yaml` file to define how the Collector should handle traces. -**collector-config.yaml** +collector-config.yaml {@include: ../../_include/tracing-shipping/collector-config.md} -#### **Build Docker Images** +#### Build Docker Images Build Docker images for both the Java application and the OpenTelemetry Collector: @@ -1325,7 +1325,7 @@ docker build --platform linux/amd64 -t java-app:latest . cd ../otel-collector/ docker build --platform linux/amd64 -t otel-collector:latest . ``` -#### **Push Docker Images to Amazon ECR** +#### Push Docker Images to Amazon ECR Push both images to your Amazon ECR repository: @@ -1341,11 +1341,20 @@ docker tag otel-collector:latest .dkr.ecr..amazonaws.com docker push .dkr.ecr..amazonaws.com/otel-collector:latest ``` -#### **Define ECS Task** +##### Log Group Creation: + +Create log groups for your Java application and OpenTelemetry Collector in CloudWatch. + +```shell +aws logs create-log-group --log-group-name /ecs/java-app +aws logs create-log-group --log-group-name /ecs/otel-collector +``` + +#### Define ECS Task Create a task definition (`task-definition.json`) for ECS that defines both the Java application container and the OpenTelemetry Collector container. -#### **task-definition.json** +#### task-definition.json ```json { @@ -1406,7 +1415,7 @@ Create a task definition (`task-definition.json`) for ECS that defines both the } ``` -#### **Deploy to ECS** +#### Deploy to ECS Create an ECS Cluster: Create a cluster to deploy your containers: @@ -1432,6 +1441,6 @@ aws ecs create-service \ --network-configuration "awsvpcConfiguration={subnets=[\"YOUR_SUBNET_ID\"],securityGroups=[\"YOUR_SECURITY_GROUP_ID\"],assignPublicIp=ENABLED}" ``` -#### **Verify Application and Tracing** +#### Verify Application and Tracing After deploying, run your application to generate activity that will create tracing data. Wait a few minutes, then check the Logz.io dashboard to confirm that traces are being sent correctly. \ No newline at end of file diff --git a/docs/shipping/Code/node-js.md b/docs/shipping/Code/node-js.md index c61929a2..81f80247 100644 --- a/docs/shipping/Code/node-js.md +++ b/docs/shipping/Code/node-js.md @@ -932,7 +932,7 @@ helm uninstall logzio-k8s-telemetry This guide provides an overview of deploying your Node.js application on Amazon ECS, using OpenTelemetry to collect and send tracing data to Logz.io. It offers a step-by-step process for setting up OpenTelemetry instrumentation and deploying both the application and OpenTelemetry Collector sidecar in an ECS environment. -##### **Prerequisites** +##### Prerequisites Before you begin, ensure you have the following prerequisites in place: @@ -946,7 +946,7 @@ Before you begin, ensure you have the following prerequisites in place: For a complete example, refer to [this repo](https://github.com/logzio/opentelemetry-examples/tree/main/nodejs/traces/ecs-service). ::: -##### **Architecture Overview** +##### Architecture Overview The deployment will involve two main components: @@ -969,7 +969,7 @@ project-root/ ``` -#### **Steps to Deploy the Application** +#### Steps to Deploy the Application 1. Project Structure Setup @@ -979,7 +979,7 @@ project-root/ Add OpenTelemetry instrumentation to your Node.js application by including a tracing setup `tracing.js`. This file will initialize OpenTelemetry and configure the trace exporter to send traces to the OpenTelemetry Collector. -##### **tracing.js** +##### tracing.js ```javascript "use strict"; @@ -1028,7 +1028,7 @@ The `tracing.js` file initializes OpenTelemetry tracing, configuring the OTLP ex Include the tracing setup at the entry point of your application `app.js`, ensuring tracing starts before any other logic. -##### **Dockerfile** +##### Dockerfile ```dockerfile # Use Node.js LTS version @@ -1058,15 +1058,15 @@ CMD ["npm", "start"] The Dockerfile installs the necessary dependencies, sets the environment variables required for OpenTelemetry configuration, and starts the application. -##### **Configure the OpenTelemetry Collector** +##### Configure the OpenTelemetry Collector The OpenTelemetry Collector receives traces from the application and exports them to Logz.io. Create a `collector-config.yaml` file to define how the Collector should handle traces. -##### **collector-config.yaml** +##### collector-config.yaml {@include: ../../_include/tracing-shipping/collector-config.md} -##### **Build Docker Images** +##### Build Docker Images Build Docker images for both the Node.js application and the OpenTelemetry Collector: @@ -1080,7 +1080,7 @@ cd ../otel-collector/ docker build --platform linux/amd64 -t otel-collector:latest . ``` -##### **Push Docker Images to Amazon ECR** +##### Push Docker Images to Amazon ECR Push both images to your Amazon ECR repository: @@ -1096,11 +1096,20 @@ docker tag otel-collector:latest .dkr.ecr..amazonaws.com docker push .dkr.ecr..amazonaws.com/otel-collector:latest ``` -##### **Define ECS Task** +##### Log Group Creation: + +Create log groups for your Nodejs application and OpenTelemetry Collector in CloudWatch. + +```shell +aws logs create-log-group --log-group-name /ecs/nodejs-app +aws logs create-log-group --log-group-name /ecs/otel-collector +``` + +##### Define ECS Task Create a task definition (task-definition.json) for ECS that defines both the Node.js application container and the OpenTelemetry Collector container. -##### **task-definition.json** +##### task-definition.json ```json { @@ -1161,7 +1170,7 @@ Create a task definition (task-definition.json) for ECS that defines both the No } ``` -##### **Deploy to ECS** +##### Deploy to ECS - Create an ECS Cluster: Create a cluster to deploy your containers: @@ -1188,7 +1197,7 @@ Create a task definition (task-definition.json) for ECS that defines both the No --region \ ``` -###### **Verify Application and Tracing** +##### Verify Application and Tracing After deploying, run your application to generate activity that will create tracing data. Wait a few minutes, then check the Logz.io dashboard to confirm that traces are being sent correctly. diff --git a/docs/shipping/Code/python.md b/docs/shipping/Code/python.md index afd9c120..fb1c52d1 100644 --- a/docs/shipping/Code/python.md +++ b/docs/shipping/Code/python.md @@ -1348,11 +1348,11 @@ Give your traces time to process, after which they'll be available in your [Trac -### Python Application Setup for ECS Service with OpenTelemetry +## Python Application Setup for ECS Service with OpenTelemetry This guide provides an overview of deploying your Python application on Amazon ECS, using OpenTelemetry to collect and send tracing data to Logz.io. It offers a step-by-step process for setting up OpenTelemetry instrumentation and deploying both the application and OpenTelemetry Collector sidecar in an ECS environment. -##### **Prerequisites** +#### Prerequisites Before you begin, ensure you have the following prerequisites in place: @@ -1366,7 +1366,7 @@ Before you begin, ensure you have the following prerequisites in place: For a complete example, refer to [this repo](https://github.com/logzio/opentelemetry-examples/tree/main/python/traces/ecs-service). ::: -##### **Architecture Overview** +#### Architecture Overview The deployment will involve two main components: @@ -1393,7 +1393,7 @@ project-root/ └── Dockerfile # Dockerfile for the Collector ``` -##### **Steps to Deploy the Application** +#### Steps to Deploy the Application 1. Project Structure Setup @@ -1405,7 +1405,7 @@ project-root/ Install dependencies: -##### **requirements.txt** +#### requirements.txt ``` flask @@ -1416,11 +1416,11 @@ opentelemetry-instrumentation-flask The package `opentelemetry-instrumentation-flask` handles the automatic instrumentation of Flask at runtime. -##### **Dockerize Your Application** +#### Dockerize Your Application Create a Dockerfile to build a Docker image of your Python application. Below is the Dockerfile to get started: -#### **Dockerfile** +#### Dockerfile ```dockerfile FROM python:3.8-slim @@ -1441,15 +1441,15 @@ EXPOSE 5000 CMD ["opentelemetry-instrument", "python", "app.py"] ``` -##### **Configure the OpenTelemetry Collector** +#### Configure the OpenTelemetry Collector The OpenTelemetry Collector receives traces from the application and exports them to Logz.io. Create a `collector-config.yaml` file to define how the Collector should handle traces. -##### **collector-config.yaml** +#### collector-config.yaml {@include: ../../_include/tracing-shipping/collector-config.md} -##### **Build Docker Images** +#### Build Docker Images Build Docker images for both the Node.js application and the OpenTelemetry Collector: @@ -1463,7 +1463,7 @@ cd ../otel-collector/ docker build --platform linux/amd64 -t otel-collector:latest . ``` -##### **Push Docker Images to Amazon ECR** +#### Push Docker Images to Amazon ECR Push both images to your Amazon ECR repository: @@ -1479,11 +1479,20 @@ docker tag otel-collector:latest .dkr.ecr..amazonaws.com docker push .dkr.ecr..amazonaws.com/otel-collector:latest ``` -##### **Define ECS Task** +##### Log Group Creation: + +Create log groups for your Python application and OpenTelemetry Collector in CloudWatch. + +```shell +aws logs create-log-group --log-group-name /ecs/python-app +aws logs create-log-group --log-group-name /ecs/otel-collector +``` + +#### Define ECS Task Create a task definition (task-definition.json) for ECS that defines both the Node.js application container and the OpenTelemetry Collector container. -##### **task-definition.json** +#### task-definition.json ```json { @@ -1544,7 +1553,7 @@ Create a task definition (task-definition.json) for ECS that defines both the No } ``` -##### **Deploy to ECS** +#### Deploy to ECS - Create an ECS Cluster: Create a cluster to deploy your containers: @@ -1571,7 +1580,7 @@ Create a task definition (task-definition.json) for ECS that defines both the No --region \ ``` -###### **Verify Application and Tracing** +#### Verify Application and Tracing After deploying, run your application to generate activity that will create tracing data. Wait a few minutes, then check the Logz.io dashboard to confirm that traces are being sent correctly. @@ -1632,9 +1641,9 @@ logzio-monitoring logzio-helm/logzio-monitoring -n monitoring Typically, the service name will be `logzio-k8s-telemetry.default.svc.cluster.local`, where `default` is the namespace where you deployed the helm chart and `svc.cluster.name` is your cluster domain name. If you're unsude what your cluster domain name is, run the following command to find it: -```sh +```shell kubectl run -it --image=k8s.gcr.io/e2e-test-images/jessie-dnsutils:1.3 --restart=Never shell -- \ -shell -c 'nslookup kubernetes.default | grep Name | sed "s/Name:\skubernetes.default//"' +sh -c 'nslookup kubernetes.default | grep Name | sed "s/Name:\skubernetes.default//"' ``` This command deploys a pod to extract your cluster domain name, which can be removed after.