Skip to content

Expose erlang application metrics in a standardised, protocol agnostic format

License

Notifications You must be signed in to change notification settings

outlyerapp/metrics-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metrics_reader

Hex pm

An application that exposes Folsom metrics in common standardised formats.

This is important for several reasons:

  • Applications provide a common interface for the same purpose
  • Exposing application metrics in standardised formats allows existing tools to scrape these metrics e.g. Prometheus
  • Knowledge is transferable when the same problem is solved in a consistent manner.

The metrics reader exposes the application metrics via an rpc call to the nodetool:

./bin/metrics_reader metrics

The metrics reader server

Metrics should be registered with the metrics reader server if they are to be reported via the console:

metrics_reader:register(subscriber_acks).

It is also possible to de-register a registered metric:

metrics_reader:deregister(subscriber_acks).

Finally, in order to examine the registered metrics:

metrics_reader:metrics().

The metrics observer server

For scalar metrics, it is possible to periodically snapshot the values and record the resulting values in a histogram. This allows richer statistics to be derived from simple scalar values. Be aware that observing a metric will cause the server to clear the metric's current value every time it is sampled.

In order to observe a metric, it is necessary to provide a name for the histogram that will be created:

metrics_observer:observe(subscriber_acks, subscriber_acks_per_second).

It is also possible to unobserve a metric:

metrics_observer:unobserve(subscriber_acks).

Configuration

{format, prometheus_format}                         # defaults to prometheus exposition format
{histogram_acc_interval_sec, 10}                    # defaults to 1 second
{histogram_slide_interval_sec, 60}                  # defaults to 60 second

Export formats

An export_format behaviour is defined that consists of the following callbacks:

callback histogram(Name :: binary(), Histogram :: #{}) -> 
   [binary()].

An default prometheus_format formatter is already provided that will convert the metric values to the prometheus textual exposition format.

Build

$ rebar3 compile

In order to run tests...{to do}

Release

$ rebar3 release

About

Expose erlang application metrics in a standardised, protocol agnostic format

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published