Pub Version

This is a simple Dart implementation of the Prometheus client library, similar to to libraries for other languages. It supports the default metric types like gauges, counters, summaries, or histograms. Metrics can be exported using the text format. To expose them in your server application the package comes with the package prometheus_client_shelf to integrate metrics with a shelf handler. In addition, it comes with some plug-in ready metrics for the Dart runtime.

You can find the latest updates in the changelog.


A simple usage example:

import 'dart:io';

import 'package:prometheus_client/format.dart' as format;
import 'package:prometheus_client/prometheus_client.dart';
import 'package:prometheus_client/runtime_metrics.dart' as runtime_metrics;

main() async {
  // Register runtime metrics with the default metrics registry

  // Create a Histogram metrics without labels. Always register your metric,
  // either at the default registry or a custom one.
  final durationHistogram = Histogram(
    name: 'http_request_duration_seconds',
    help: 'The duration of http requests in seconds.',

  // Create a metric of type counter, with a label for the requested path:
  final metricRequestsCounter = Counter(
      name: 'metric_requests_total', 
      help: 'The total amount of requests of the metrics.',
      labelNames: ['path'],

  // Create a http server
  final server = await HttpServer.bind(
  print('Listening on localhost:${server.port}');

  await for (HttpRequest request in server) {
    // Measure the request duration
    await durationHistogram.observeDuration(Future(() async {
      // Count calls to the metric endpoint by path.

      // Output metrics in the text representation
      request.response.headers.add('content-type', format.contentType);
      await request.response.close();

Start the example application and access the exposed metrics at http://localhost:8080/. For a full usage example, take a look at example/prometheus_client_example.dart.

Features and bugs

Please file feature requests and bugs at the issue tracker.


A library containing the core elements of the Prometheus client, like the CollectorRegistry and different types of metrics like Counter, Gauge and Histogram.
A library to export metrics in the Prometheus text representation.
A library exposing metrics of the Dart runtime.