Technical “How-To’s”

How to Monitor Host Metrics with OpenTelemtry

Austin Senkowski
Austin Senkowski
Share:

OpenTelemetry is at the core of standardizing telemetry solutions. At observIQ, we’re focused on building the very best in open source telemetry software. Our relationship with OpenTelemetry began in 2021, with observIQ, contributing our logging agent, Stanza, to the OpenTelemetry community. Now, we are shifting our focus to simplifying OpenTelemetry solutions to its large base of users. On that note, we launched a collector that combines the best of both worlds, with OpenTelemetry at its core, combined with observIQ’s functionalities to simplify its usage.

In this post, we are taking you through the installation of the observIQ distribution of the OpenTelemetry collector and the steps to configure the collector to gather host metrics, eventually forwarding those metrics to the Google Cloud Operations.

Step 1: Installing the collector

The simplest way to get started is with one of the single-line installation commands shown below. For more advanced options, you’ll find a variety of installation options for Linux, Windows, and macOS on GitHub.

Use the following single-line installation script to install the observiq-otel collector.

Please note that the collector must be installed on the system which you wish to collect host metrics from.

Windows:

bash
1msiexec /i "https://github.com/observIQ/observiq-otel-collector/releases/latest/download/observiq-otel-collector.msi" /quiet

Linux:

bash
1sudo sh -c "$(curl -fsSlL https://github.com/observiq/observiq-otel-collector/releases/latest/download/install_unix.sh)" install_unix.sh

Step 2: Setting up pre-requisites and authentication credentials

In the following example, we are using Google Cloud Operations as the destination. However, OpenTelemtry offers exporters for many destinations. Check out the list of exporters here.

Setting up Google Cloud exporter prerequisites:

If running outside of Google Cloud (On prem, AWS, etc) or without the Cloud Monitoring scope, the Google Exporter requires a service account.

Create a service account with the following roles:

  • Metrics: roles/monitoring.metricWriter
  • Logs: roles/logging.logWriter

Create a service account JSON key and place it on the system that is running the collector.

MacOS/Linux

In this example, the key is placed at /opt/observiq-otel-collector/sa.json and its permissions are restricted to the user running the collector process.

bash
1sudo cp sa.json /opt/observiq-otel-collector/sa.json
2sudo chown observiq-otel-collector: /opt/observiq-otel-collector/sa.json
3sudo chmod 0400 /opt/observiq-otel-collector/sa.json

Set the GOOGLE_APPLICATION_CREDENTIALS environment variable by creating a systemd override. A systemd override allows users to modify the systemd service configuration without modifying the service directly. This allows package upgrades to happen seamlessly. You can learn more about systemd units and overrides here.

Run the following command

bash
1sudo systemctl edit observiq-otel-collector

If this is the first time an override is being created, paste the following contents into the file:

text
1[Service] Environment=GOOGLE_APPLICATION_CREDENTIALS=/opt/observiq-otel-collector/sa.json

If an override is already in place, simply insert the Environment parameter into the existing Service section.

Restart the collector

bash
1sudo systemctl restart observiq-otel-collector

Windows

In this example, the key is placed at C:/observiq/collector/sa.json.

Set the GOOGLE_APPLICATION_CREDENTIALS with the command prompt setx command.

Run the following command

bash
1setx GOOGLE_APPLICATION_CREDENTIALS "C:/observiq/collector/sa.json" /m

Restart the service using the services application.

Step 3: Configuring the collector

In this sample configuration, the steps to use the host metrics receiver to fetch metrics from the host system and export them to Google Cloud Operations are detailed. This is how it works:

  1. The collector scrapes metrics and logs from the host and exports them to a destination assigned in the configuration file.
  2. To export the metrics to Google Cloud Operations, use the configurations outlined in the googlecloudexporter

After the installation, the config file for the collector can be found at:

  • C:\Program Files\observIQ OpenTelemetry Collector\config.yaml (Windows)
  • /opt/observiq-otel-collector/config.yaml (Linux)

Edit the configuration file and use the following configuration.

yaml
1# Receivers collect metrics from a source. The host metrics receiver will
2# get CPU load metrics about the machine the collector is running on
3# every minute.
4receivers:
5  hostmetrics:
6  collection_interval: 60s
7  scrapers:
8    cpu:
9    disk:
10    load:
11    filesystem:
12    memory:
13    network:
14    paging:
15    processes:
16
17# Processors are run on data between being received and being exported.
18processors:
19  # Resourcedetection is used to add a unique (host.name)
20  # to the metric resource(s), allowing users to filter
21  # between multiple systems.
22  resourcedetection:
23  detectors: ["system"]
24  system:
25    hostname_sources: ["os"]
26
27  # Resourceattributetransposer is used to add labels to metrics.
28  resourceattributetransposer:
29  operations:
30    # Process metrics require unique metric labels, otherwise the Google
31    # API will reject some metrics as "out of order" / duplicates.
32    - from: "host.name"
33        to: "hostname"
34    - from: "process.pid"
35        to: "pid"
36    - from: "process.executable.name"
37        to: "binary"
38 
39  # Normalizesums smoothes out data points for more
40  # comprehensive visualizations.
41  normalizesums:
42
43  # The batch processor aggregates incoming metrics into a batch,
44  # releasing them if a certain time has passed or if a certain number
45  # of entries have been aggregated.
46  batch:
47
48# Exporters send the data to a destination, in this case GCP.
49exporters:
50  googlecloud:
51  retry_on_failure:
52    enabled: false
53  metric:
54    prefix: custom.googleapis.com
55
56# Service specifies how to construct the data pipelines using
57# the configurations above.
58service:
59  pipelines:
60  metrics:
61    receivers:
62    - hostmetrics
63    processors:
64    - resourcedetection
65    - resourceattributetransposer
66    - normalizesums
67    - batch
68    exporters:
69    - googlecloud

3. Restart the collector

text
1systemctl restart observiq-otel-collector

Step 3: Viewing the metrics in Google Cloud Operations

You should now be able to view the host metrics in your Metrics explorer. Nice work! This is how simple it is to collect host metrics in Linux.

Metrics collected

MetricDescriptionNamespace
Processes CreatedTotal number of created processes.custom.googleapis.com/opencensus/system.processes.created
Process CountTotal number of processes in each state.custom.googleapis.com/opencensus/system.processes.count
Process CPU timeTotal CPU seconds broken down by different states.custom.googleapis.com/opencensus/process.cpu.time
Process Disk IODisk bytes transferred.custom.googleapis.com/opencensus/process.disk.io
File System Inodes UsedFileSystem inodes used.custom.googleapis.com/opencensus/system.filesystem.inodes.usage
File System UtilizationFilesystem bytes used.custom.googleapis.com/opencensus/system.filesystem.usage
Process Physical Memory UtilizationThe amount of physical memory in use.custom.googleapis.com/opencensus/process.memory.physical_usage
Process Virtual Memory UtilizationVirtual memory size.custom.googleapis.com/opencensus/process.memory.virtual_usage
Networking ErrorsThe number of errors encountered.custom.googleapis.com/opencensus/system.network.errors
Networking ConnectionsThe number of connections.custom.googleapis.com/opencensus/system.network.connections

Conclusion

observIQ’s distribution is a game-changer for companies looking to implement the OpenTelemetry standards. The single line installer, seamlessly integrated receivers, exporter, and processor pool make working with this collector simple. Follow this space to keep up with all our future posts and simplified configurations for various sources. For questions, requests, and suggestions, reach out to our support team at support@observIQ.com.

Austin Senkowski
Austin Senkowski
Share:

Related posts

All posts

Get our latest content
in your inbox every week

By subscribing to our Newsletter, you agreed to our Privacy Notice

Community Engagement

Join the Community

Become a part of our thriving community, where you can connect with like-minded individuals, collaborate on projects, and grow together.

Ready to Get Started

Deploy in under 20 minutes with our one line installation script and start configuring your pipelines.

Try it now