🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@opentelemetry/exporter-prometheus

Package Overview
Dependencies
Maintainers
3
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/exporter-prometheus

OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus

0.201.1
latest
Source
npm
Version published
Weekly downloads
1.3M
-7.37%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/exporter-prometheus?

@opentelemetry/exporter-prometheus is an npm package that allows you to export OpenTelemetry metrics to Prometheus. It provides a way to expose metrics collected by OpenTelemetry to be scraped by a Prometheus server.

What are @opentelemetry/exporter-prometheus's main functionalities?

Setup Prometheus Exporter

This code sets up a Prometheus exporter that starts an HTTP server on port 9464 to expose metrics. It creates a meter provider and a counter metric, which is then incremented by 10.

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

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

const meterProvider = new MeterProvider({
  exporter,
  interval: 1000,
});

const meter = meterProvider.getMeter('example-meter');
const counter = meter.createCounter('example_counter', {
  description: 'An example counter',
});

counter.add(10, { key: 'value' });

Customizing Exporter Options

This code demonstrates how to customize the Prometheus exporter options, such as changing the port and endpoint for the metrics server.

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

const exporter = new PrometheusExporter({
  port: 8080,
  endpoint: '/custom-metrics',
  startServer: true,
}, () => {
  console.log('Prometheus scrape endpoint: http://localhost:8080/custom-metrics');
});

const meterProvider = new MeterProvider({
  exporter,
  interval: 1000,
});

const meter = meterProvider.getMeter('example-meter');
const counter = meter.createCounter('example_counter', {
  description: 'An example counter',
});

counter.add(10, { key: 'value' });

Other packages similar to @opentelemetry/exporter-prometheus

Keywords

opentelemetry

FAQs

Package last updated on 19 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts