Prometheus.ex v1.0.0-alpha3 Prometheus

Prometheus.io client library powered by prometheus.erl

Prometheus.ex is a thin, mostly macro-based wrapper around prometheus.erl. While it’s pretty straightforward to use prometheus.erl from Elixir, you might prefer prometheus.ex because it gives you:

  • native Elixir syntax;
  • native Elixir exceptions;
  • configuration helpers that are really handy if you plan to write your custom instrumenter.
defmodule ExampleInstrumenter do
  use Prometheus.Metric

  def setup do
    Histogram.new([name: :http_request_duration_milliseconds,
                   labels: [:method],
                   buckets: [100, 300, 500, 750, 1000],
                   help: "Http Request execution time"])
  end

  def instrument(%{time: time, method: method}) do
    Histogram.observe([name: :http_request_duration_milliseconds, labels: [method]], time)
  end
end

Integrations

API

API can be grouped like this:

Standard Metrics & Registry

All metrics created via new/1 or declare/1 macros. The difference is new/1 actually wants metric to be new and raises Prometheus.Error.MFAlreadyExists if it isn’t.

Both new/1 and declare/1 accept options as Keyword. Common options are:

  • name - metric name, can be an atom or a string (required);
  • help - metric help, string (required);
  • labels - metric labels, label can be an atom or a string (default is []);
  • registry - Prometheus registry for the metric, can be any term. (default is :default)

Histogram also accepts buckets option. Please refer to respective modules docs for the more information.

General Helpers

Integration Helpers

  • Prometheus.Config - provides standard configuration mechanism for custom instrumenters/exporters.

Exposition Formats

Advanced

You will need this modules only if you’re writing custom collector for app/lib that can’t be instrumented directly.

  • Prometheus.Collector - exports macros for managing/creating collectors;
  • Prometheus.Model - provides API for working with underlying Prometheus models. You’ll use that if you want to create custom collector.