0.35.4 • Published 9 months ago

@opentelemetry/host-metrics v0.35.4

Weekly downloads
143
License
Apache-2.0
Repository
github
Last release
9 months ago

OpenTelemetry Host Metrics for Node.js

NPM Published Version Apache License

This module provides automatic collection of Host Metrics which includes metrics for:

  • CPU
  • Memory
  • Network

Compatible with OpenTelemetry JS API and SDK 1.0+.

Installation

npm install --save @opentelemetry/host-metrics

Usage

const { MeterProvider } = require('@opentelemetry/sdk-metrics');
const { HostMetrics } = require('@opentelemetry/host-metrics');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');

const exporter = new PrometheusExporter(
  {
    startServer: true
  }, () => {
    console.log('prometheus scrape endpoint: http://localhost:9464/metrics')
  }
);

const meterProvider = new MeterProvider({
  readers: [reader],
});

const hostMetrics = new HostMetrics({ meterProvider });
hostMetrics.start();

Semantic Conventions

This package uses Semantic Conventions Version 1.25.0. As for now the Semantic Conventions are bundled in this package but eventually will be imported from @opentelemetry/semantic-conventions package when it is updated to latest version. Ref: opentelemetry-js/issues/4235

Metrics collected:

MetricShort Description
system.cpu.timeSeconds each logical CPU spent on each mode
system.cpu.utilizationCPU usage time (0-1)
system.memory.usageReports memory in use by state
system.memory.utilizationMemory usage (0-1)
system.network.droppedCount of packets that are dropped
system.network.errorsCount of network errors detected
system.network.ioNetwork flow direction
process.cpu.timeTotal CPU seconds
process.cpu.utilizationDifference in process.cpu.time since the last measurement
process.memory.usageThe amount of physical memory in use

Attributes collected:

MetricShort Description
system.cpu.logical_numberThe logical CPU number
system.cpu.stateThe state of the CPU
system.memory.stateThe memory state
system.deviceThe device identifier
network.io.directionThe network IO operation direction
system.network.stateThe network state
process.cpu.stateThe CPU state

Useful links

License

APACHE 2.0 - See LICENSE for more information.