BuildImplementation guide4 min read

VM Implementation Guide

By Nicolas Narbais

Operate a Linux VM Collector that captures host evidence, Collector health, local logs, and OTLP from local applications.

Last updated on

Run one systemd-managed otelcol-contrib agent on a Linux VM (AWS, GCP, Azure, or on-prem) across three levels to capture host/systemd metrics, local logs, Collector self-metrics, cloud metadata, and loopback OTLP from local apps.

LevelGoalWhat it proves
1Install host agent (script or manual)Validated systemd unit, loopback-only OTLP, root-only secrets
2Verify host metrics, logs & self-metricsHost appears in Tsuga Hosts; logs arrive once
3Receive local application OTLPApp trace keeps its own service.name and populates Service page
flowchart LR APP["Local applications"] -->|"OTLP 127.0.0.1:4317 / :4318"| COL["otelcol-contrib (systemd)"] HOST["Host metrics, systemd, logs, cloud metadata"] --> COL COL -->|"OTLP/HTTP gzip"| TS["Tsuga: Hosts, Metrics, Logs, Traces"] COL --> HC["127.0.0.1:13133 health"] COL --> SM["127.0.0.1:8888 self-metrics"]

This guide sets up host observability and a local OTLP intake. Instrument each application separately with its own service.name before sending traces in Level 3.

Before starting

  • Supported OS: systemd-based Linux (Ubuntu, Debian, Amazon Linux, RHEL, Rocky, AlmaLinux, CentOS Stream, Fedora, openSUSE, SLES).
  • Access & egress: sudo access, disk space for checkpoint storage, and outbound HTTPS to GitHub (package download) and Tsuga.
  • Secrets: store Tsuga OTLP endpoint and ingestion key in VM bootstrap secret storage, never in Collector YAML or Git.
  • Identity: agree on SERVICE_NAMESPACE, DEPLOYMENT_ENVIRONMENT_NAME, and HOST_ALIAS without overwriting application service.name.
  • Single log source: choose file logs or journald per stream; never collect mirrored streams twice.
  • Cloud tags: allowlist stable keys only (Name, Environment, Service). EC2 requires Allow tags in instance metadata (IMDS); GCP requires roles/compute.viewer; Azure tags attach directly to the VM.

Level 1 - Run the Collector as a host agent

Pick one install method per fleet: Option A (default) automates checksum verification, startup ordering, config validation, and health checks; Option B gives full manual OS control.

Exit criteria: otelcol-contrib is enabled and healthy, config validates with otelcol-contrib, and secrets live in a root-only (0600) env file.

Option A - Install with the pinned script (default)

Download the pinned gist revision and review both files before running with sudo (never pipe directly to a shell; mirror internally if outbound third-party fetches are disallowed):

curl -fsSL -o tsuga_otel_install.sh \
  'https://gist.githubusercontent.com/nxnarbais/b8de0fa84fe752aee96d75d67ac47038/raw/d023b77d93611d820d439522ab2992bcdbd33409/tsuga_otel_install.sh'
curl -fsSL -o otel-config.yaml \
  'https://gist.githubusercontent.com/nxnarbais/b8de0fa84fe752aee96d75d67ac47038/raw/d023b77d93611d820d439522ab2992bcdbd33409/otel-config.yaml'
chmod 0755 tsuga_otel_install.sh

Export secrets and identity in your shell, then run the installer (SERVICE_NAMESPACE groups related services like payments; keep service.name per app and use HOST_ALIAS for the VM):

export TSUGA_ENDPOINT='<TSUGA_OTLP_ENDPOINT>'
export TSUGA_API_KEY='<TSUGA_INGESTION_KEY>'
export SERVICE_NAMESPACE='<TEAM_OR_PRODUCT>'
export DEPLOYMENT_ENVIRONMENT='production'
export HOST_ALIAS='<RECOGNIZABLE_HOST_NAME>'

./tsuga_otel_install.sh ./otel-config.yaml

Optional installer flags:

  • Dry-run plan: OTELCOL_BOOTSTRAP_PLAN=1 ./tsuga_otel_install.sh
  • Enable journald (only if /var/log files do not mirror it): export OTELCOL_ENABLE_JOURNALD=true
  • Container runtime override: OTELCOL_CONFIG_PROFILE=baseline|docker|containerd|docker-containerd (auto-detected by default; override only when the local socket/endpoint exists).

The script writes secrets to /etc/otelcol-contrib/tsuga.env (0600), config to /etc/otelcol-contrib/config.yaml, and install logs to /var/log/cloud-vm-bootstrap/install.log.

Option B - Install and configure manually

1. Install otelcol-contrib (pinned 0.154.0)

Core otelcol lacks required Contrib receivers/processors. Mask the service before package install so it does not start before secrets and config exist:

export OTELCOL_VERSION='0.154.0'

case "$(uname -m)" in
  x86_64|amd64) export OTELCOL_ARCH='amd64' ;;
  aarch64|arm64) export OTELCOL_ARCH='arm64' ;;
  *) echo 'Unsupported architecture'; exit 1 ;;
esac

. /etc/os-release
case " ${ID} ${ID_LIKE:-} " in
  *' debian '*|*' ubuntu '*) export OTELCOL_PACKAGE='deb' ;;
  *) export OTELCOL_PACKAGE='rpm' ;;
esac

export OTELCOL_FILE="otelcol-contrib_${OTELCOL_VERSION}_linux_${OTELCOL_ARCH}.${OTELCOL_PACKAGE}"
export OTELCOL_RELEASE="https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTELCOL_VERSION}"

sudo systemctl mask otelcol-contrib.service
curl -fLO "${OTELCOL_RELEASE}/${OTELCOL_FILE}"
curl -fsSLO "${OTELCOL_RELEASE}/opentelemetry-collector-releases_otelcol-contrib_checksums.txt"
expected_checksum="$(awk -v file="${OTELCOL_FILE}" '$2 == file { print $1; exit }' opentelemetry-collector-releases_otelcol-contrib_checksums.txt)"
[ -n "${expected_checksum}" ] || { echo 'Checksum not found'; exit 1; }
printf '%s  %s\n' "${expected_checksum}" "${OTELCOL_FILE}" | sha256sum --check --strict

if [ "${OTELCOL_PACKAGE}" = deb ]; then
  sudo dpkg -i "${OTELCOL_FILE}"
else
  sudo rpm -Uvh "${OTELCOL_FILE}"
fi

sudo install -d -m 0750 /var/lib/otelcol-contrib/storage
sudo install -d -m 0755 /etc/otelcol-contrib /etc/systemd/system/otelcol-contrib.service.d
sudo ln -sfn / /hostfs

2. Write the root-only environment file

sudo tee /etc/otelcol-contrib/tsuga.env >/dev/null <<'EOF'
TSUGA_OTLP_ENDPOINT=<TSUGA_OTLP_ENDPOINT>
TSUGA_API_KEY=<TSUGA_INGESTION_KEY>
SERVICE_NAMESPACE=<TEAM_OR_PRODUCT>
DEPLOYMENT_ENVIRONMENT_NAME=production
HOST_ALIAS=<RECOGNIZABLE_HOST_NAME>
COLLECTOR_LOG_LEVEL=info
EOF
sudo chmod 0600 /etc/otelcol-contrib/tsuga.env
sudo chown root:root /etc/otelcol-contrib/tsuga.env

3. Write /etc/otelcol-contrib/config.yaml

Use sudoedit /etc/otelcol-contrib/config.yaml with this baseline (enable Docker, containerd, or journald only after confirming local socket/permissions):

extensions:
  health_check:
    endpoint: 127.0.0.1:13133
  file_storage:
    directory: /var/lib/otelcol-contrib/storage
    create_directory: true

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 127.0.0.1:4317
      http:
        endpoint: 127.0.0.1:4318
  hostmetrics:
    collection_interval: 10s
    root_path: /hostfs
    scrapers:
      cpu:
        metrics:
          system.cpu.utilization:
            enabled: true
      disk:
      filesystem:
        metrics:
          system.filesystem.utilization:
            enabled: true
      load:
      memory:
        metrics:
          system.memory.limit:
            enabled: true
          system.memory.utilization:
            enabled: true
      paging:
        metrics:
          system.paging.utilization:
            enabled: true
      processes:
      process:
        mute_process_all_errors: true
        include:
          match_type: regexp
          names:
            - ^(otelcol-contrib|dockerd|containerd|containerd-shim.*)$
        metrics:
          process.cpu.utilization:
            enabled: true
          process.memory.utilization:
            enabled: true
          process.threads:
            enabled: true
      system:
  systemd:
    collection_interval: 10s
    scope: system
    units:
      - otelcol-contrib.service
      - docker.service
      - containerd.service
      - systemd-journald.service
    metrics:
      systemd.service.restarts:
        enabled: true
  prometheus/self:
    config:
      scrape_configs:
        - job_name: otel-collector
          scrape_interval: 10s
          static_configs:
            - targets: [127.0.0.1:8888]
  filelog/system:
    include:
      - /var/log/syslog
      - /var/log/messages
      - /var/log/*.log
    start_at: end
    storage: file_storage
    include_file_name: true
    include_file_path: true

processors:
  memory_limiter:
    check_interval: 5s
    limit_percentage: 80
    spike_limit_percentage: 25
  resourcedetection/cloud:
    detectors: [env, gcp, azure, ec2, system]
    override: false
    timeout: 2s
    ec2:
      tags:
        - (?i)^name$
        - (?i)^environment$
        - (?i)^service$
      tags_from_imds: true
    gcp:
      labels:
        - (?i)^name$
        - (?i)^environment$
        - (?i)^service$
    azure:
      tags:
        - (?i)^name$
        - (?i)^environment$
        - (?i)^service$
  resource/common:
    attributes:
      - key: service.namespace
        value: ${env:SERVICE_NAMESPACE}
        action: insert
      - key: deployment.environment.name
        value: ${env:DEPLOYMENT_ENVIRONMENT_NAME}
        action: insert
  resource/collector:
    attributes:
      - key: service.name
        value: vm-otel-collector
        action: insert
  cumulativetodelta: {}
  batch:
    timeout: 1s
    send_batch_size: 1024
    send_batch_max_size: 2048

connectors:
  spanmetrics:
    dimensions:
      - name: http.request.method
        default: GET
      - name: http.response.status_code
      - name: http.route

exporters:
  otlphttp/tsuga:
    endpoint: ${env:TSUGA_OTLP_ENDPOINT}
    compression: gzip
    headers:
      Authorization: Bearer ${env:TSUGA_API_KEY}
    timeout: 10s

service:
  extensions: [health_check, file_storage]
  telemetry:
    resource:
      service.name: vm-otel-collector
      service.namespace: ${env:SERVICE_NAMESPACE}
      deployment.environment.name: ${env:DEPLOYMENT_ENVIRONMENT_NAME}
      host.name: ${env:HOST_ALIAS}
    logs:
      level: ${env:COLLECTOR_LOG_LEVEL:-info}
    metrics:
      level: normal
      readers:
        - pull:
            exporter:
              prometheus:
                host: 127.0.0.1
                port: 8888
  pipelines:
    metrics:
      receivers: [hostmetrics, systemd, otlp, spanmetrics, prometheus/self]
      processors: [memory_limiter, resourcedetection/cloud, resource/common, resource/collector, cumulativetodelta, batch]
      exporters: [otlphttp/tsuga]
    logs:
      receivers: [filelog/system, otlp]
      processors: [memory_limiter, resourcedetection/cloud, resource/common, resource/collector, batch]
      exporters: [otlphttp/tsuga]
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resourcedetection/cloud, resource/common, batch]
      exporters: [spanmetrics, otlphttp/tsuga]

4. Wire the systemd drop-in and start

sudo tee /etc/systemd/system/otelcol-contrib.service.d/tsuga.conf >/dev/null <<'EOF'
[Service]
EnvironmentFile=/etc/otelcol-contrib/tsuga.env
EOF

sudo systemctl unmask otelcol-contrib.service
sudo systemctl daemon-reload
sudo systemctl enable --now otelcol-contrib

Level 2 - Validate host collection

Verify config, unit health, loopback endpoints, and logs on the VM first:

sudo otelcol-contrib validate --config=/etc/otelcol-contrib/config.yaml
sudo systemctl status otelcol-contrib --no-pager
curl -fsS http://127.0.0.1:13133/
curl -fsS http://127.0.0.1:8888/metrics | grep '^otelcol_' | head
sudo journalctl -u otelcol-contrib -n 100 --no-pager

Within one scrape interval, verify system.cpu.utilization, system.processes.count, systemd.unit.state, and otelcol_exporter_sent_metric_points in Tsuga, confirm the host appears in Hosts, and emit one distinctive log line to verify single-copy ingestion.

Exit criteria: Host, process, systemd, and Collector self-metrics appear in Tsuga with stable host, cloud, namespace, and environment context; the host appears in Hosts; and logs arrive once.

Level 3 - Accept OTLP from local applications

Point host-local applications to 127.0.0.1:4317 (gRPC) or 127.0.0.1:4318 (HTTP). The baseline inserts service.namespace and deployment.environment.name without overwriting service.name, omits resource/collector on traces, and runs spanmetrics so traced services populate Tsuga’s Service page.

Warning

Containers do not share host loopback: Inside Docker or containerd, 127.0.0.1 refers to the container itself. Configure explicit container-to-host networking or a reachable Collector endpoint instead.

Exit criteria: A local application exports a known trace through loopback, arrives under its own service.name (not vm-otel-collector), and populates its Service page via spanmetrics.

Make it operational

Scope VM monitoring to the infrastructure owner and aggregate by fleet, environment, or role (never one monitor per VM in an autoscaling group):

  • Host pressure: alert on sustained CPU saturation, memory exhaustion, and per-mount system.filesystem.utilization (/var fills long before / looks full).
  • Collector health: alert the platform team on export errors, queue pressure, drops, or otelcol-contrib unit failure.
  • Fleet dashboard: CPU, memory, load, filesystem, disk I/O, and Collector export health filtered by host/fleet.

Troubleshooting path

Validate in order: otelcol-contrib validate → unit status → :13133 health → :8888 self-metrics → Tsuga search.

SymptomCheck firstFix
Service crashes on startotelcol-contrib validate --config=/etc/otelcol-contrib/config.yamlValidate with otelcol-contrib (not core otelcol) and check missing sockets
No telemetry reaches Tsugajournalctl -u otelcol-contrib + /etc/otelcol-contrib/tsuga.envVerify base OTLP URL, secret key, and outbound HTTPS
Local apps cannot reach OTLPTarget address (127.0.0.1) and container network namespaceUse loopback on host processes; route containers explicitly
Docker receiver breaks startupDocker socket presence & permissionsLeave Docker disabled unless socket is readable (use auto profile in script)
Cloud tags missingEC2 IMDS tag toggle, GCP compute.viewer, Azure VM tagsGrant read access and keep tag allowlist tight
Duplicate or missing host logsFile log paths vs journald overlap and permissionsPick one source per stream; verify Debian vs RPM log paths

Completion criterion and CLI validation

Host metrics appear in Hosts under the expected name/environment, host logs arrive once, and a local application’s traces arrive with the application’s own service.name.

# 1. Confirm the host log line arrived with expected host identity
tsuga logs search \
  --query "context.host.name:<host> <unique-log-token>" \
  --from -15m \
  --to now \
  --max-results 10

# 2. Confirm a local app exported spans under its own service.name
tsuga traces search \
  --query "context.service.name:<service>" \
  --from -15m \
  --to now \
  --max-results 10

If command 1 lacks the expected host name, inspect resourcedetection/cloud and HOST_ALIAS. If command 2 shows unknown_service, set OTEL_SERVICE_NAME in the application rather than stamping it in the Collector. Verify host metrics directly in Tsuga Hosts and Metrics.

References

Written by

Nicolas Narbais

Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.

Olatuak Editorial Philosophy

Better signal, not more telemetry.

Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.

Scroll to zoom · Drag to pan · Double-click to reset