@opentelemetry/exporter-prometheus
    TypeScript icon, indicating that this package has built-in type declarations

    0.26.0 • Public • Published

    OpenTelemetry Prometheus Metric Exporter

    NPM Published Version dependencies devDependencies Apache License

    The OpenTelemetry Prometheus Metrics Exporter allows the user to send collected OpenTelemetry Metrics to Prometheus.

    Prometheus is a monitoring system that collects metrics, by scraping exposed endpoints at regular intervals, evaluating rule expressions. It can also trigger alerts if certain conditions are met. For assistance setting up Prometheus, Click here for a guided codelab.

    Installation

    npm install --save @opentelemetry/sdk-metrics-base
    npm install --save @opentelemetry/exporter-prometheus

    Usage

    Create & register the exporter on your application.

    const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
    const { MeterProvider }  = require('@opentelemetry/sdk-metrics-base');
    
    // Add your port and startServer to the Prometheus options
    const options = {port: 9464, startServer: true};
    const exporter = new PrometheusExporter(options);
    
    // Register the exporter
    const meter = new MeterProvider({
      exporter,
      interval: 1000,
    }).getMeter('example-prometheus');
    
    // Now, start recording data
    const counter = meter.createCounter('metric_name', {
      description: 'Example of a counter'
    });
    counter.add(10, { pid: process.pid });
    
    // Record data using Instrument: It is recommended to keep a reference to the Bound Instrument instead of
    // always calling `bind()` method for every operations.
    const boundCounter = counter.bind({ pid: process.pid });
    boundCounter.add(10);
    
    // .. some other work

    Viewing your metrics

    With the above you should now be able to navigate to the Prometheus UI at: http://localhost:9464/metrics

    Useful links

    License

    Apache 2.0 - See LICENSE for more information.

    Install

    npm i @opentelemetry/exporter-prometheus

    DownloadsWeekly Downloads

    10,853

    Version

    0.26.0

    License

    Apache-2.0

    Unpacked Size

    74.4 kB

    Total Files

    24

    Last publish

    Collaborators

    • mayurkale22
    • bogdandrutu
    • dyladan
    • obecny