Skip to content
Last9 named a Gartner Cool Vendor in AI for SRE Observability for 2025! Read more →
Last9

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
  1. Install OpenTelemetry Collector

    You can install either rpm or deb package 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.rpm
    sudo rpm -ivh otelcol-contrib_0.118.0_linux_amd64.rpm

    More installation options can be found here.

  2. Configure OpenTelemetry Collector

    Create the configuration file:

    sudo nano /etc/otel-contrib-collector/config.yaml

    Use the following configuration for OpenTelemetry Collector:

    receivers:
    filelog:
    # File path pattern to read system logs from.
    include: [/var/log/*.log]
    include_file_path: true
    retry_on_failure:
    enabled: true
    hostmetrics:
    collection_interval: 60s
    scrapers:
    cpu:
    metrics:
    system.cpu.logical.count:
    enabled: true
    memory:
    metrics:
    system.memory.utilization:
    enabled: true
    system.memory.limit:
    enabled: true
    load:
    disk:
    filesystem:
    metrics:
    system.filesystem.utilization:
    enabled: true
    network:
    paging:
    processes:
    process:
    mute_process_user_error: true
    mute_process_io_error: true
    mute_process_exe_error: true
    metrics:
    process.cpu.utilization:
    enabled: true
    process.memory.utilization:
    enabled: true
    processors:
    batch:
    timeout: 20s
    send_batch_size: 10000
    send_batch_max_size: 10000
    resourcedetection/system:
    detectors: ["system"]
    system:
    hostname_sources: ["os"]
    resourcedetection/cloud:
    detectors: ["aws", "gcp", "azure"]
    transform/hostmetrics:
    metric_statements:
    - context: datapoint
    statements:
    - 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: true
    log_statements:
    - context: resource
    statements:
    - set(attributes["service.name"], "hostmetrics") # Change this as needed
    - set(attributes["deployment.environment"], "staging") # Change this as needed
    exporters:
    otlp/last9:
    endpoint: "{{ .Logs.WriteURL }}"
    headers:
    "Authorization": "{{ .Logs.AuthValue }}"
    debug:
    verbosity: detailed
    service:
    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]
  3. Configure the OpenTelemetry Collector Service

    Create the service file:

    sudo nano /etc/systemd/system/otelcol-contrib.service

    Add the following:

    [Unit]
    Description=OpenTelemetry Collector Contrib with custom flags
    After=network.target
    [Service]
    ExecStart=/usr/bin/otelcol-contrib --config /etc/otelcol-contrib/config.yaml --feature-gates transform.flatten.logs
    Restart=always
    User=root
    Group=root
    [Install]
    WantedBy=multi-user.target
  4. Start the OpenTelemetry Collector Service

    Reload systemd to apply changes and start the service:

    sudo systemctl daemon-reload
    sudo systemctl enable otelcol-contrib
    sudo systemctl start otelcol-contrib

Verification

Verify Configuration and Monitor Logs:

Check the service status:

sudo systemctl status otelcol-contrib

Monitor logs in real-time:

sudo journalctl -u otelcol-contrib -f

Log into your Last9 account to confirm host metrics are being received.

Need Help?

If you encounter any issues or have questions: