#!/bin/bash # Check if the required number of arguments are provided if [ "$#" -ne 2 ]; then echo "Usage: $0 " exit 1 fi URL=$1 AUTH_KEY=$2 # Ensure 'openobserve-agent' user and group exist if ! id -u openobserve-agent &>/dev/null; then useradd --system openobserve-agent usermod -aG systemd-journal openobserve-agent # add user to systemd-journal so it can access journald logs fi if ! grep -q "^openobserve-agent:" /etc/group; then groupadd openobserve-agent fi # Detect OS and architecture OS=$(uname | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) OTEL_VERSION="0.111.0" if [ "$ARCH" = "x86_64" ]; then ARCH="amd64" elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi # Construct the download URL DOWNLOAD_URL="https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/otelcol-contrib_${OTEL_VERSION}_${OS}_${ARCH}.tar.gz" # Download the otel-collector binary curl -L $DOWNLOAD_URL -o otelcol-contrib.tar.gz # Extract the binary tar -xzf otelcol-contrib.tar.gz # make the binary executable chmod +x otelcol-contrib # Move the binary to /usr/local/bin mv otelcol-contrib /usr/local/bin/ # Generate a sample configuration file cat > /etc/otel-config.yaml < /etc/systemd/system/otel-collector.service <