DEV Community

Ezzio Moreira
Ezzio Moreira

Posted on

4

OpenTelemetry Collector ElasticBeanStalk

Este guia descreve os passos para implementar o OpenTelemetry Collector no Elastic Beanstalk utilizando .ebextension. O processo inclui baixar o binário do OpenTelemetry Collector, configurar um serviço do Linux, copiar o arquivo de configuração e iniciar o serviço.

1. Criar a Pasta .ebextensions

Primeiro, crie um diretório chamada .ebextensions no diretório raiz da sua aplicação.

2. Baixar o Binário do OpenTelemetry Collector

Crie um arquivo de configuração chamado 01_download_collector.config no diretório .ebextensions para baixar o binário do OpenTelemetry Collector.

files:
  "/opt/otelcol-contrib/otelcol-contrib":
    mode: "000755"
    owner: ec2-user
    group: ec2-user
    source: https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.103.1/otelcol-contrib_0.103.1_linux_arm64.tar.gz

commands:
  extract_otel_collector:
    command: "tar -xvzf /opt/otelcol-contrib/otelcol-contrib -C /opt/otelcol-contrib/"
Enter fullscreen mode Exit fullscreen mode

3. Criar o Serviço Linux para OtelColl

Crie um arquivo de configuração chamado 02_create_service.config para configurar um serviço systemd para o OpenTelemetry Collector.

files:
  "/etc/systemd/system/otelcol-contrib.service":
    mode: "000644"
    owner: root
    group: root
    content: |
      [Unit]
      Description=OpenTelemetry Collector Contrib
      After=network.target

      [Service]
      User=ec2-user
      ExecStart=/opt/otelcol-contrib/otelcol-contrib --config=/etc/otelcol-contrib/config.yaml
      Restart=always

      [Install]
      WantedBy=multi-user.target

commands:
  reload_systemd:
    command: "sudo systemctl daemon-reload"
  enable_service:
    command: "sudo systemctl enable otelcol-contrib"
Enter fullscreen mode Exit fullscreen mode

4. Copiar o Arquivo de Configuração

Crie um arquivo de configuração chamado 03_copy_config.config para copiar o arquivo de configuração do OpenTelemetry Collector.

files:
  "/etc/otelcol-contrib/config.yaml":
    mode: "000644"
    owner: ec2-user
    group: ec2-user
    content: |
      receivers:
        otlp:
          protocols:
            grpc:
              endpoint: "0.0.0.0:4317"
            http:
              endpoint: "0.0.0.0:4318"

        prometheus:
          config:
            scrape_configs:
              - job_name: otelcoll-metrics
                scrape_interval: 60s
                static_configs:
                  - targets: ['localhost:8888']

      processors:
        batch:
          send_batch_max_size: 1000
          timeout: 60s
          send_batch_size: 800

        memory_limiter:
          check_interval: 1s
          limit_percentage: 70
          spike_limit_percentage: 30

        resourcedetection:
          detectors: [env, elastic_beanstalk, ec2]
          timeout: 2s
          override: false

        attributes/logs:
          actions:
            - action: insert
              key: loki.attribute.labels
              value: event.domain, event.name
            - action: insert
              key: loki.format
              value: json

        resource/logs:
          attributes:
            - action: insert
              key: loki.resource.labels
              value: service.name

      exporters:
        loki:
          endpoint: http://ENPOINT:3100/loki/api/v1/push
          tls:
            insecure: true

        otlphttp/tempo:
          endpoint: http://ENPOINT:4318
          tls:
            insecure: true

        prometheusremotewrite:
          endpoint: http://ENPOINT:9009/api/v1/push
          resource_to_telemetry_conversion:
            enabled: true
          target_info:
            enabled: false

      service:
        telemetry:
          logs:
            level: info
          metrics:
            address: 0.0.0.0:8888

      pipelines:
        traces:
          receivers: [otlp]
          processors: [resourcedetection, batch, memory_limiter]
          exporters: [otlphttp/tempo]

        metrics:
          receivers: [otlp, prometheus]
          processors: [resourcedetection, batch, memory_limiter]
          exporters: [prometheusremotewrite]

        logs:
          receivers: [otlp]
          processors: [resourcedetection, resource/logs, attributes/logs, batch, memory_limiter]
          exporters: [loki]
Enter fullscreen mode Exit fullscreen mode

5. Iniciar o Serviço

Crie um arquivo de configuração chamado 04_start_service.config para iniciar o serviço do OpenTelemetry Collector.

commands:
  start_otel_service:
    command: |
      sudo systemctl start otelcol-contrib
      sudo systemctl status otelcol-contrib
Enter fullscreen mode Exit fullscreen mode

Resumo

Esta abordagem garante que o coletor inicie corretamente e comece a enviar dados para o Grafana após o lançamento da instância.

Referencia

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay