Host Metrics on Raspberry Pi
Monitor Raspberry Pi host metrics including CPU, memory, disk, network, system load, and temperature using OpenTelemetry Collector with Last9
Use OpenTelemetry to monitor Raspberry Pi host metrics including CPU, memory, disk, network, system load, and CPU/GPU temperature.
Prerequisites
Before setting up Raspberry Pi host metrics monitoring, ensure you have:
- Raspberry Pi (any model) running Raspberry Pi OS
- SSH access to your Pi
- Last9 account with integration credentials
-
Determine Your Pi’s Architecture
Run this command to check your Pi’s architecture:
uname -marmv7l→ 32-bit (uselinux_armv7package)aarch64→ 64-bit (uselinux_arm64package)
-
Install OpenTelemetry Collector
Note: systemd is required for automatic service configuration.
For Raspberry Pi 4/5 with 64-bit OS:
sudo apt-get updatesudo apt-get -y install wgetwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.144.0/otelcol-contrib_0.144.0_linux_arm64.debsudo dpkg -i otelcol-contrib_0.144.0_linux_arm64.debFor Raspberry Pi 3 and older, or 32-bit OS:
sudo apt-get updatesudo apt-get -y install wgetwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.144.0/otelcol-contrib_0.144.0_linux_armv7.debsudo dpkg -i otelcol-contrib_0.144.0_linux_armv7.debMore installation options can be found here.
-
Configure OpenTelemetry Collector
Create the configuration file:
sudo nano /etc/otelcol-contrib/config.yamlUse the following configuration optimized for Raspberry Pi:
receivers:hostmetrics:collection_interval: 30sscrapers:cpu:metrics:system.cpu.utilization:enabled: truesystem.cpu.logical.count:enabled: truememory:metrics:system.memory.utilization:enabled: truesystem.memory.limit:enabled: trueload:disk:filesystem:metrics:system.filesystem.utilization:enabled: truenetwork:processes:process:mute_process_user_error: truemute_process_io_error: truemute_process_exe_error: truemetrics:process.cpu.utilization:enabled: trueprocess.memory.utilization:enabled: true# Raspberry Pi temperature (requires pi-temp-exporter)prometheus/pi_temp:config:scrape_configs:- job_name: 'pi-temperature'scrape_interval: 30sstatic_configs:- targets: ['localhost:9101']processors:# Memory limiter to prevent OOM on resource-constrained Pimemory_limiter:check_interval: 5slimit_mib: 100spike_limit_mib: 25batch:timeout: 10ssend_batch_size: 1000send_batch_max_size: 2000resourcedetection/system:detectors: ["system"]system:hostname_sources: ["os"]resource/pi:attributes:- key: device.typevalue: raspberry-piaction: upserttransform/hostmetrics:metric_statements:- context: datapointstatements:- set(attributes["host.name"], resource.attributes["host.name"])- set(attributes["os.type"], resource.attributes["os.type"])exporters:otlp/last9:endpoint: "{{ .Metrics.WriteURL }}"headers:"Authorization": "{{ .Metrics.AuthValue }}"service:pipelines:metrics:receivers: [hostmetrics, prometheus/pi_temp]processors: [memory_limiter, batch, resourcedetection/system, resource/pi, transform/hostmetrics]exporters: [otlp/last9] -
Install Temperature Exporter (Optional)
To collect CPU/GPU temperature and throttle state:
# Download the exportersudo curl -o /usr/local/bin/pi-temp-exporter.py \https://raw.githubusercontent.com/last9/opentelemetry-examples/main/otel-collector/raspberry-pi/pi-temp-exporter.pysudo chmod +x /usr/local/bin/pi-temp-exporter.py# Create and start servicesudo tee /etc/systemd/system/pi-temp-exporter.service > /dev/null <<EOF[Unit]Description=Raspberry Pi Temperature ExporterAfter=network.target[Service]Type=simpleExecStart=/usr/bin/python3 /usr/local/bin/pi-temp-exporter.pyRestart=alwaysUser=root[Install]WantedBy=multi-user.targetEOFsudo systemctl daemon-reloadsudo systemctl enable pi-temp-exportersudo systemctl start pi-temp-exporter -
Start the OpenTelemetry Collector Service
Reload systemd to apply changes and start the service:
sudo systemctl daemon-reloadsudo systemctl enable otelcol-contribsudo systemctl start otelcol-contrib
Verification
Check the service status:
sudo systemctl status otelcol-contribMonitor logs in real-time:
sudo journalctl -u otelcol-contrib -fLog into your Last9 account to confirm host metrics are being received.
Collected Metrics
| Category | Metrics |
|---|---|
| CPU | Usage per core, utilization, load averages |
| Memory | Used, free, cached, buffers, utilization |
| Disk | Usage, I/O operations, read/write bytes |
| Filesystem | Usage per mount point |
| Network | Bytes sent/received, packets, errors |
| Load | 1m, 5m, 15m averages |
| Process | Count, CPU/memory per process |
| Temperature | CPU temp, GPU temp, throttle state (with pi-temp-exporter) |
Resource Optimization
For Raspberry Pi Zero or older models with limited resources, increase the collection interval and reduce batch sizes:
receivers: hostmetrics: collection_interval: 60s # Instead of 30s
processors: batch: send_batch_size: 500 send_batch_max_size: 1000Need Help?
If you encounter any issues or have questions:
- Join our Discord community for real-time support
- Contact our support team at support@last9.io