Ubuntu Host Metrics
Monitor Ubuntu server metrics including CPU, memory, disk, network, and processes using OpenTelemetry collector with Last9
Use OpenTelemetry to instrument host metrics.
Read the setup guide for more details.
Prerequisites
Before setting up Ubuntu host metrics monitoring, ensure you have:
- Ubuntu server with administrative access
- OpenTelemetry Collector installation access
- Last9 account with integration credentials
-
Install OpenTelemetry Collector
You can install either
rpmordebpackage depending on flavor of operating system you are using.Note: systemd is required for automatic service configuration.
Installing rpm package:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.rpmsudo rpm -ivh otelcol-contrib_0.118.0_linux_amd64.rpmInstalling deb package:
sudo apt-get updatesudo apt-get -y install wget systemctlwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.debsudo dpkg -i otelcol-contrib_0.118.0_linux_amd64.debMore installation options can be found here.
-
Configure OpenTelemetry Collector
Create the configuration file:
sudo nano /etc/otel-contrib-collector/config.yamlUse the following configuration for OpenTelemetry Collector:
receivers:filelog:# File path pattern to read system logs from.include: [/var/log/*.log]include_file_path: trueretry_on_failure:enabled: truehostmetrics:collection_interval: 60sscrapers:cpu:metrics:system.cpu.logical.count:enabled: truememory:metrics:system.memory.utilization:enabled: truesystem.memory.limit:enabled: trueload:disk:filesystem:metrics:system.filesystem.utilization:enabled: truenetwork:paging:processes:process:mute_process_user_error: truemute_process_io_error: truemute_process_exe_error: truemetrics:process.cpu.utilization:enabled: trueprocess.memory.utilization:enabled: trueprocessors:batch:timeout: 20ssend_batch_size: 10000send_batch_max_size: 10000resourcedetection/system:detectors: ["system"]system:hostname_sources: ["os"]resourcedetection/cloud:detectors: ["aws", "gcp", "azure"]transform/hostmetrics:metric_statements:- context: datapointstatements:- set(attributes["host.name"], resource.attributes["host.name"])- set(attributes["cloud.account.id"], resource.attributes["cloud.account.id"])- set(attributes["cloud.availability_zone"], resource.attributes["cloud.availability_zone"])- set(attributes["cloud.platform"], resource.attributes["cloud.platform"])- set(attributes["cloud.provider"], resource.attributes["cloud.provider"])- set(attributes["cloud.region"], resource.attributes["cloud.region"])- set(attributes["host.type"], resource.attributes["host.type"])- set(attributes["host.image.id"], resource.attributes["host.image.id"])transform/logs:flatten_data: truelog_statements:- context: resourcestatements:- set(attributes["service.name"], "hostmetrics") # Change this as needed- set(attributes["deployment.environment"], "staging") # Change this as neededexporters:otlp/last9:endpoint: "{{ .Logs.WriteURL }}"headers:"Authorization": "{{ .Logs.AuthValue }}"debug:verbosity: detailedservice:pipelines:logs:receivers: [filelog]processors:[batch,resourcedetection/system,resourcedetection/cloud,transform/logs,]exporters: [otlp/last9]metrics:receivers: [hostmetrics]processors:[batch,resourcedetection/system,resourcedetection/cloud,transform/hostmetrics,]exporters: [otlp/last9] -
Configure the OpenTelemetry Collector Service
Create the service file:
sudo nano /etc/systemd/system/otelcol-contrib.serviceAdd the following:
[Unit]Description=OpenTelemetry Collector Contrib with custom flagsAfter=network.target[Service]ExecStart=/usr/bin/otelcol-contrib --config /etc/otelcol-contrib/config.yaml --feature-gates transform.flatten.logsRestart=alwaysUser=rootGroup=root[Install]WantedBy=multi-user.target -
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
Verify Configuration and Monitor Logs:
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.
Need 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