Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.gitignore
.travis.yml
README.md
rebar.config
rebar.lock

README.md

exometer_fetch

This reporter acts as subscription handler such that other services (e.g. http server) can fetch metrics from it.

Build Status Hex pm

Usage

Add exometer_fetch to your list of dependencies in rebar.config:

{deps, [
    {exometer_fetch, "0.1.0"}
]}.

Ensure exometer_fetch is started before your application:

{applications, [exometer_fetch]}.

Configure it:

{exometer,
    {reporters, [
        {exometer_report_fetch, [
            {autosubscribe, true},
            {subscriptions_module, exometer_fetch_subscribe_mod}
        ]}
    ]}
}.

It is possible to create a subscription automatically for each newly created metric entry. By default this is disabled. You can enable it in the reporter options. You must also provide a callback module which handles the entries. Apart from that there are no further options.

The callback module may look like:

-module(exometer_fetch_subscribe_mod).
-export([subscribe/2]).

subscribe([test, metric] = Metric, histogram) ->
    {Metric, [max, min], [{key, <<"some_key">>}]};
subscribe(_, _) -> [].

subscribe/2 calls for each new entry and it should return a (possibly empty) list or just one subscription. Here a single subscription has the following layout:

{exometer_report:metric(), exometer_report:datapoints(), exometer_report:extra()}

Subscription examples:

exometer_report:subscribe(exometer_report_fetch, [erlang, memory], total, manual, [{key, <<"some_key">>}]).

Check if everything is working:

exometer_fetch:fetch(<<"some_key">>).

Further it is possible to return only the value of a specific datapoint:

exometer_fetch:fetch(<<"some_key">>, total).

Keys always need to be given as binary. If a key is not found then all metrics which have this key as prefix will be returned (or an error if nothing is found).

About subscription time intervals:

The report interval in subscriptions should be set to manual such that the metric is actually never reported using time interval triggers. The metric value will be retrieved from exometer directly when one sends a request to the corresponding key.

You can’t perform that action at this time.