• Stars
    star
    338
  • Rank 120,492 (Top 3 %)
  • Language
    Erlang
  • License
    MIT License
  • Created about 8 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Prometheus.io client in Erlang

Prometheus.io client for Erlang

Copyright (c) 2016,2017 Ilya Khaprov <[email protected]>.

Version: 4.10.0

Hex.pm Hex.pm Build Status Coverage Status

Prometheus.io monitoring system and time series database client in Erlang.

RabbitMQ Dashboard

  • IRC: #erlang on Freenode;
  • Slack: #prometheus channel - Browser or App(slack://elixir-lang.slack.com/messages/prometheus).

Integrations

Dashboards

Blogs

Erlang VM & OTP Collectors

Compatibility

OTP versions

Version 3.x works on OTP18+. For older version (oldest tested is R16B03) please use 3.x-pre18 branch. 3.x-pre18 will work on all OTP releases starting from R16B03 and its beam will recompile itself to accommodate. For example, this branch is used by RabbitMQ Exporter 3.6.x that should be compatible with all versions starting from R16B03.

Build tools

Rebar3 and rebar2 are supported.

Example Console Session

Run shell with compiled and loaded app:


    $ rebar3 shell

Start prometheus app:


prometheus:start().

Register metrics:

prometheus_gauge:new([{name, pool_size}, {help, "MongoDB Connections pool size"}]),
prometheus_counter:new([{name, http_requests_total}, {help, "Http request count"}]).
prometheus_summary:new([{name, orders}, {help, "Track orders count/total sum"}]).
prometheus_histogram:new([{name, http_request_duration_milliseconds},
                               {labels, [method]},
                               {buckets, [100, 300, 500, 750, 1000]},
                               {help, "Http Request execution time"}]).

Use metrics:

prometheus_gauge:set(pool_size, 365),
prometheus_counter:inc(http_requests_total).
prometheus_summary:observe(orders, 10).
prometheus_summary:observe(orders, 15).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 95).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 100).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 102).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 150).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 250).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 75).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 350).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 550).
prometheus_histogram:observe(http_request_duration_milliseconds, [get], 950).
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 500),
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 150).
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 450).
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 850).
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 750).
prometheus_histogram:observe(http_request_duration_milliseconds, [post], 1650).

Export metrics as text:

io:format(prometheus_text_format:format()).

->

# TYPE http_requests_total counter
# HELP http_requests_total Http request count
http_requests_total 2
# TYPE pool_size gauge
# HELP pool_size MongoDB Connections pool size
pool_size 365
# TYPE orders summary
# HELP orders Track orders count/total sum
orders_count 4
orders_sum 50
# TYPE http_request_duration_milliseconds histogram
# HELP http_request_duration_milliseconds Http Request execution time
http_request_duration_milliseconds_bucket{method="post",le="100"} 0
http_request_duration_milliseconds_bucket{method="post",le="300"} 1
http_request_duration_milliseconds_bucket{method="post",le="500"} 3
http_request_duration_milliseconds_bucket{method="post",le="750"} 4
http_request_duration_milliseconds_bucket{method="post",le="1000"} 5
http_request_duration_milliseconds_bucket{method="post",le="+Inf"} 6
http_request_duration_milliseconds_count{method="post"} 6
http_request_duration_milliseconds_sum{method="post"} 4350
http_request_duration_milliseconds_bucket{method="get",le="100"} 3
http_request_duration_milliseconds_bucket{method="get",le="300"} 6
http_request_duration_milliseconds_bucket{method="get",le="500"} 7
http_request_duration_milliseconds_bucket{method="get",le="750"} 8
http_request_duration_milliseconds_bucket{method="get",le="1000"} 9
http_request_duration_milliseconds_bucket{method="get",le="+Inf"} 9
http_request_duration_milliseconds_count{method="get"} 9
http_request_duration_milliseconds_sum{method="get"} 2622

API

API can be grouped like this:

Standard Metrics & Registry

All metrics created via new/1 or declare/1. The difference is that new/1 actually wants metric to be new and raises {mf_already_exists, {Registry, Name}, Message} error if it isn't.

Both new/1 and declare/1 accept options as proplist. 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.

Exposition Formats

General Helpers

Advanced

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

Build

   $ rebar3 compile

Configuration

Prometheus.erl supports standard Erlang app configuration.

  • collectors - List of custom collectors modules to be registered automatically. If undefined list of all modules implementing prometheus_collector behaviour will be used.
  • default_metrics - List of metrics to be registered during app startup. Metric format: {Type, Spec} where Type is a metric type (counter, gauge, etc), Spec is a list to be passed to Metric:declare/1. Deprecated format {Registry, Metric, Spec} also supported.

Collectors config also supports "alias" option default. When used these collectors will be registered:

prometheus_boolean,
prometheus_counter,
prometheus_gauge,
prometheus_histogram,
prometheus_mnesia_collector,
prometheus_summary,
prometheus_vm_memory_collector,
prometheus_vm_statistics_collector,
prometheus_vm_system_info_collector

Collectors & Exporters Conventions

Configuration

All 3d-party libraries should be configured via prometheus app env.

Exproters are responsible for maintianing scrape endpoint. Exporters usually tightly coupled with web server and are singletons. They should understand these keys:

  • path - url for scraping;
  • format - scrape format as module name i.e. prometheus_text_format or prometheus_protobuf_format. Exporter-specific options should be under <exporter_name>_exporter for erlang or <Exporter_name>Exporter for Elixir i.e. PlugsExporter or elli_exporter

Collectors collect integration specific metrics i.e. ecto timings, process informations and so on. Their configuration should be under <collector_name>_collectorfor erlang or <Collector_name>Collector for Elixir i.e. process_collector, EctoCollector and so on.

Naming

For Erlang: prometheus_<name>_collector/prometheus_<name>_exporter.

For Elixir: Prometheus.<name>Collector/Prometheus.<name>Exporter.

Contributing

Sections order:

Types -> Macros -> Callbacks -> Public API -> Deprecations -> Private Parts

install git precommit hook:

   ./bin/pre-commit.sh install

Pre-commit check can be skipped passing --no-verify option to git commit.

License

MIT

Modules

prometheus_boolean
prometheus_buckets
prometheus_collector
prometheus_counter
prometheus_format
prometheus_gauge
prometheus_histogram
prometheus_http
prometheus_mnesia
prometheus_mnesia_collector
prometheus_model_helpers
prometheus_protobuf_format
prometheus_quantile_summary
prometheus_registry
prometheus_summary
prometheus_text_format
prometheus_time
prometheus_vm_dist_collector
prometheus_vm_memory_collector
prometheus_vm_msacc_collector
prometheus_vm_statistics_collector
prometheus_vm_system_info_collector

More Repositories

1

prometheus.ex

Prometheus.io Elixir client
Elixir
395
star
2

prometheus_rabbitmq_exporter

Prometheus.io exporter as a RabbitMQ Managment Plugin plugin
Erlang
282
star
3

beam-dashboards

BEAM ❤️ Prometheus ❤️ Grafana
282
star
4

ssl_verify_fun.erl

Collection of ssl verification functions for Erlang
Erlang
96
star
5

prometheus.cl

Prometheus.io Common Lisp client
Common Lisp
79
star
6

prometheus-ecto

Prometheus.io collector for Elixir.Ecto
Elixir
74
star
7

prometheus-phoenix

Prometheus.io Phoenix instrumenter
Elixir
69
star
8

prometheus-plugs

Prometheus.erl Elixir Plugs
Elixir
53
star
9

prometheus_process_collector

Prometheus.io process collector in Erlang
C++
47
star
10

prometheus-httpd

Expose Prometheus metrics using inets httpd.
Erlang
23
star
11

prometheus-cowboy

Expose Prometheus metrics using cowboy/cowboy2
Erlang
21
star
12

smerl

Simple Metaprogramming for Erlang
Erlang
20
star
13

slime-repl-ansi-color

I found this code here http://lists.common-lisp.net/pipermail/slime-devel/2012-March/018497.html . Original Author is Max Mikhanosha.
Emacs Lisp
17
star
14

cl-events

Events (Hooks) for Common Lisp
Common Lisp
12
star
15

safe-queue

Thread-safe queues and mailboxes
Common Lisp
11
star
16

cl-emb

GitHub mirror for http://common-lisp.net/project/cl-emb/
Common Lisp
11
star
17

rebar3_elvis_plugin

Run Elvis as rebar3 plugin
Erlang
10
star
18

prometheus-push

Prometheus.io pushgateway client
Erlang
9
star
19

accept

Accept* headers for Erlang/Elixir
Erlang
9
star
20

cl-statsd

Statsd client in Common Lisp
Common Lisp
8
star
21

http-routes

Http routes library for Common Lisp, see tests for usage
Common Lisp
8
star
22

cl-smtp

Github fork of cl-smtp, just for convenience.
Common Lisp
7
star
23

quantile-estimator.cl

Common Lisp implementation of Graham Cormode and S. Muthukrishnan's Effective Computation of Biased Quantiles over Data Streams in ICDE’05
Common Lisp
6
star
24

amqp_rpc

RPC Client/Server for amqp Elixir library
Elixir
6
star
25

slackin.ex

Slackin in Elixir. Demo:
Elixir
6
star
26

extjs-rails

ExtJS gem rails assets pipline integration gem
Ruby
6
star
27

rebar3_archive_plugin

Create Erlang Code archives (.ez)
Erlang
5
star
28

dot-emacs

My Emacs configs
Emacs Lisp
4
star
29

iomux-acceptor

Evented IO for Hunchentoot using IOLIB.
Common Lisp
4
star
30

mongodb-erlang-pool

Simple Pool for Mongodb-Erlang
Erlang
4
star
31

cowboy_routes_tree

Organize cowboy routes in trees
Erlang
4
star
32

erlang-template

My Erlang app/library template
Shell
3
star
33

counters.erl

Erlang
3
star
34

clws

websockets server in CL
Common Lisp
3
star
35

cl-dropbox

Dropbox Core SDK in Common Lisp
Common Lisp
3
star
36

thrift.erl

Conveniently packaged Apache Thrift
Erlang
2
star
37

prometheus-plugs-example

Prometheus Plugs example app
Elixir
1
star
38

semaphore

HTML
1
star
39

twtgit

Tweet repositories, issues, pull requests and releases. Supports GitHub, Bitbucket and Gitlab
JavaScript
1
star
40

cl-uri-template

RFC6570 URI templates expander
Common Lisp
1
star
41

stripe-cl

Stripe API in Common Lisp
Common Lisp
1
star
42

nixos-playground

My NixOS Expirement
1
star
43

countries.beam

Erlang
1
star
44

ia-hash-table

Indifferent access hash-tables for Common Lisp. Also with dot syntax
Common Lisp
1
star
45

hyper-drakma

Common Lisp
1
star
46

cl-link-field-parser

Naive parser for HTTP Link header field
Common Lisp
1
star
47

mongodb-csharp-xtras

Some Additional code like ASP.NET Membership & Role Providers, serializer and etc
1
star