Skip to content

Instantly share code, notes, and snippets.

@calebhailey
Created July 27, 2022 23:16
Show Gist options
  • Save calebhailey/ee04fa473fa787a791d285a878554f4d to your computer and use it in GitHub Desktop.
Save calebhailey/ee04fa473fa787a791d285a878554f4d to your computer and use it in GitHub Desktop.

Sumo Logic OpenTelemetry Collector (OTC) Distribution

Install the collector

  1. Download and install Sumo Logic OTC Distro

    export SUMO_OTC_DISTRO_VERSION=0.56.0-sumo-0
    curl -sLo otelcol-sumo "https://github.com/SumoLogic/sumologic-otel-collector/releases/download/v${SUMO_OTC_DISTRO_VERSION}/otelcol-sumo-${SUMO_OTC_DISTRO_VERSION}-linux_amd64"
    
  2. Install the collector

    sudo mkdir -p /usr/local/bin/otelcol-sumo
    sudo mv otelcol-sumo /usr/local/bin/otelcol-sumo 
    sudo chmod +x /usr/local/bin/otelcol-sumo 
    
  3. Create a system user account for the collector

    sudo groupadd --system opentelemetry
    sudo useradd --system --gid opentelemetry --home-dir /opt/opentelemetry --shell /bin/false --comment "OpenTelemetry Collector" opentelemetry
    
  4. Verify the installation was successful

    sudo -u opentelemetry otelcol-sumo --version 
    

Configure the collector

  1. Obtain a Sumo Logic installation token (to register collectors)

    See: Installation Tokens (help.sumologic.com)

    Installation Tokens register installed collectors to your Sumo Logic account. They are assigned to your account, do not expire, and can only be used to register installed collectors. You can deactivate, reactivate, or delete tokens at any time.

    Opposed to Access Keys, you can embed your installation tokens in installation scripts confident they can't be used to make API requests if compromised. You can also freely deactivate or delete users without worrying about updating Access Keys in installation scripts since Installation Tokens are associated with your account instead of users.

  2. Set an environment variable containing the installation token

    export SUMO_OTC_INSTALL_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
  3. Initialize collector statefile and config directories and/or files

    sudo mkdir /etc/otelcol-sumo
    sudo touch /etc/otelcol-sumo/config.yaml
    sudo mkdir /var/lib/otelcol-sumo
    sudo chown -R opentelemetry:opentelemetry /etc/otelcol-sumo /var/lib/otelcol-sumo
    

    Copy the following contents to /etc/otelcol-sumo/config.yaml:

    extensions:
      file_storage:
        directory: /var/lib/otelcol-sumo/file_storage
      sumologic:
        install_token: ${SUMO_OTC_INSTALL_TOKEN}
        collector_credentials_directory: /var/lib/otelcol-sumo
        collector_name: ${HOSTNAME}
        collector_category: mission-s3m
        collector_description: Sumo Logic OTC Distro Demo
        collector_fields:
          mission: s3m
        clobber: true
        ephemeral: true
    
    receivers:
      filelog:
        include_file_name: false
        include_file_path_resolved: true
        start_at: end
        include:
          - /tmp/sumologic-otc-example.log
    
    exporters:
      logging:
        loglevel: info
      sumologic:
    
    service:
      extensions: [file_storage, sumologic]
      pipelines:
        logs:
          receivers: [filelog]
          exporters: [sumologic, logging]

Start the collector

  1. Start the collector

    sudo -u opentelemetry --preserve-env=SUMO_OTC_INSTALL_TOKEN otelcol-sumo --config /etc/otelcol-sumo/config.yaml 
    

    You should see some log output as the collector starts reporting internal telemetry (Prometheus exporter), enables various extensions and their configuration (including the Sumo Logic exporter extension), starts the actual exporters (including exporters loaded from extensions), then starts the processors and receivers. The collector will then log a message like "Everything is ready. Begin running and processing data." and subsequent log messages should indicate that receivers are collecting data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment