Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/exporter-prometheus

Package Overview
Dependencies
Maintainers
3
Versions
187
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.56.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
221K
increased by7.16%
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

FAQs

Package last updated on 04 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc