How to use @opentelemetry/exporter-prometheus - 1 common examples

To help you get started, we’ve selected a few @opentelemetry/exporter-prometheus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-js / examples / prometheus / index.js View on Github external
"use strict";

const { Meter } = require("@opentelemetry/metrics");
const { PrometheusExporter } = require("@opentelemetry/exporter-prometheus");

const meter = new Meter();

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

meter.addExporter(exporter);

// Monotonic counters and gauges can only be increased.
const monotonicCounter = meter.createCounter("monotonic_counter", {
  monotonic: true,
  labelKeys: ["pid"],
  description: "Example of a monotonic counter"
});

@opentelemetry/exporter-prometheus

OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus

Apache-2.0
Latest version published 12 days ago

Package Health Score

98 / 100
Full package analysis

Popular @opentelemetry/exporter-prometheus functions