# Hosts and virtual machines This recipe runs Collector Contrib `0.160.0` as a native Linux host agent. It accepts application OTLP on loopback and collects host CPU, memory, disk, filesystem, and network metrics every 30 seconds. Host metrics are upstream **beta** in this release. Install the Contrib binary for your OS and architecture using your approved package or release distribution. Confirm `otelcol-contrib --version` reports `0.160.0`. The configuration below is independent of a particular cloud VM provider. ## Start the agent Save [host-collector.yaml](examples/host-collector.yaml) in your working directory. Load the [endpoint and key](../../common.md), then set the host identity and validate: ```sh export CORRIDORA_HOST_NAME="$(hostname)" export CORRIDORA_HOST_ID="your-stable-host-id" otelcol-contrib validate --config=host-collector.yaml GOMEMLIMIT=320MiB otelcol-contrib --config=host-collector.yaml ``` Run it under a dedicated service account with access to the system measurements you need. The example deliberately omits per-process scraping, which often requires additional privileges and can create substantial volume. Configure instrumented applications on the same host to export OTLP/HTTP to `http://127.0.0.1:4318`. They retain their own service identity. The `host-metrics` resource is applied only to the host-scraper pipeline. Assign a stable, unique `CORRIDORA_HOST_ID` for each host and verify VM identities after cloning. Infrastructure interface rates use `host.id` to identify the counter source. For [session-to-host context](../../../../../operator/investigate/infrastructure-context.md), also supply the same `host.id` on this host's application spans with matching namespace and environment. Preserve each producer's identity when forwarding data from other machines. Session associations also require the deployment's authorized infrastructure classification. ## Run persistently For a Linux systemd deployment, install the binary as `/usr/local/bin/otelcol-contrib` and the config as `/etc/otelcol-contrib/host-collector.yaml`. Create the service account and protect `/etc/otelcol-contrib/corridora.env` with mode `0600`, owned by root. Supply the variables through your secret-management process: ```text CORRIDORA_OTLP_ENDPOINT=https://YOUR_INGEST_HOST CORRIDORA_INGEST_KEY=YOUR_INGEST_KEY CORRIDORA_HOST_NAME=YOUR_STABLE_HOST_NAME CORRIDORA_HOST_ID=YOUR_STABLE_HOST_ID GOMEMLIMIT=320MiB ``` Do not put shell `export` statements in this environment file. The host name should distinguish machines while remaining stable across Collector restarts. An example unit, after the `otelcol-contrib` account and files exist: ```ini [Unit] Description=Corridora OpenTelemetry host agent After=network-online.target Wants=network-online.target [Service] User=otelcol-contrib Group=otelcol-contrib EnvironmentFile=/etc/otelcol-contrib/corridora.env ExecStart=/usr/local/bin/otelcol-contrib --config=/etc/otelcol-contrib/host-collector.yaml Restart=on-failure RestartSec=5 TimeoutStopSec=60 MemoryMax=512M NoNewPrivileges=true [Install] WantedBy=multi-user.target ``` Install the unit as `otelcol-corridora.service`, reload systemd, and start it using your normal administration workflow. Verify its status and journal. The [Ansible guide](../../clouds/ansible.md) provides an automated host configuration route. ## Optional application log files For a known UTF-8 text file, merge this fragment into the host configuration. It adds a separate log pipeline and preserves the existing application OTLP pipeline. ```yaml receivers: file_log/checkout: include: [/var/log/checkout/application.log] start_at: end include_file_path: true processors: resource/checkout_logs: attributes: - key: service.name value: checkout-api action: insert service: pipelines: logs/checkout_file: receivers: [file_log/checkout] processors: [memory_limiter, resource/checkout_logs, batch] exporters: [otlp_http/corridora] ``` Grant the service account read access to only the intended files and directories. Write a fresh test line after the receiver starts. This minimal receiver stores lines as log bodies; it does not parse an application's JSON timestamp, severity, or trace IDs into OTLP fields. Add a format-specific parser or use an application logging bridge when those fields are needed. Choose one path for a given log stream to avoid collecting the same message through both an SDK and a file receiver. Checkpoints and export queues in this minimal recipe are not persistent. Rotation and restart behavior must be tested against your logging setup. ## Verify and adapt Look in **Telemetry → Metrics** for `system.cpu.time`, `system.memory.usage`, and other `system.*` metrics under `host-metrics`. Inspect `host.name`, then compare two or more scrape intervals. Use [verification](../../verification.md) separately for application spans and logs. If the Collector runs in a Linux container, its default view may be the container's system view. Host scraping requires explicit read access to host paths and a matching `root_path`; this native recipe does not mount them automatically. Filesystem access, metric availability, and process permissions differ across Windows, macOS, and Linux. Adapt scrapers to the target OS and verify rather than assuming parity.