OpenTelemetry Prometheus Metric Exporter
![Apache License](https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat)
Note: This is an experimental package under active development. New releases may include breaking changes.
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
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');
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);
const meter = meterProvider.getMeter('example-prometheus');
const counter = meter.createCounter('metric_name', {
description: 'Example of a counter'
});
counter.add(10, { pid: process.pid });
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.