opentelemetry-js/experimental/examples/prometheus
Godfrey Chan f927e82b1d
doc: migrate away from defunct `addMetricReader` in examples (#5349)
2025-01-24 09:09:31 +00:00
..
images docs: add observableGauge to the prometheus experimental example (#4267) 2024-01-25 08:52:41 +01:00
README.md chore(lint): refactor Markdown linting to use markdownlint-cli2 (#4713) 2024-05-21 14:44:23 +02:00
docker-compose.yaml docs: add docker-compose to run prometheus for the experimental example (#4268) 2023-11-09 17:17:44 +01:00
index.js doc: migrate away from defunct `addMetricReader` in examples (#5349) 2025-01-24 09:09:31 +00:00
package.json chore: prepare next release (#5274) 2024-12-18 09:49:03 +00:00
prometheus.docker.yml docs: add docker-compose to run prometheus for the experimental example (#4268) 2023-11-09 17:17:44 +01:00
prometheus.yml chore: update prometheus examples (#2939) 2022-04-30 09:48:03 +02:00

README.md

Overview

OpenTelemetry metrics allow a user to collect data and export it to a metrics backend like Prometheus.

This is a simple example that demonstrates basic metrics collection and exports those metrics to a Prometheus compatible endpoint.

Installation

# from this directory
npm install

Run the Application

# from this directory
npm run start

If you are using the default configurations, the metrics should be available at http://localhost:9464/metrics

Run Prometheus

With docker

# from this directory
docker compose up

With binary

Setup Prometheus

  • Replace the prometheus.yml provided by the Prometheus installation with the following:
global:
  scrape_interval: 15s # Default is every 1 minute.

scrape_configs:
  - job_name: 'opentelemetry'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9464']
  • Start Prometheus
# from the directory you downloaded prometheus
prometheus --config.file=prometheus.yml

Prometheus UI

If you are using the default configurations, the prometheus client will be available at http://localhost:9090

Prometheus UI showing a charted Counter

Prometheus UI showing a charted UpDownCounter

Prometheus UI showing a charted Gauge

LICENSE

Apache License 2.0