Skip to content

Commit

Permalink
move reporters configuration to app.config file
Browse files Browse the repository at this point in the history
The idea here is to allow using all available exomoter options - we can do this
by specifing them in the app.config file. User can start as many reporterts as
it want and mim just iterates over active reporters and adds subscripions for
them
  • Loading branch information
Pawel Pikula committed Aug 6, 2015
1 parent 8c0e2f1 commit fb550c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
27 changes: 8 additions & 19 deletions apps/ejabberd/src/ejabberd_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -247,27 +247,16 @@ init_metrics() ->
fun(Host) ->
mongoose_metrics:init_predefined_host_metrics(Host)
end, ?MYHOSTS),
ReporterOpts = ejabberd_config:get_local_option(metrics_reporter),
maybe_start_reporter(ReporterOpts).

maybe_start_reporter(undefined) ->
ok;
maybe_start_reporter(Opts) ->
Interval = proplists:get_value(interval, Opts, 5000),
case proplists:get_value(backend, Opts) of
graphite ->
Host = proplists:get_value(host, Opts, "localhost"),
R = mongoose_metrics:start_graphite_reporter(Host),
start_subscriptions(R, Interval);
_ ->
undefined
end.
Reporters = exometer_report:list_reporters(),
lists:foreach(
fun({Name, _Reporter}) ->
Interval = application:get_env(exometer, mongooseim_interval, 5000),
start_subscriptions(Name, Interval)
end, Reporters).

start_subscriptions({ok, Reporter}, Interval) ->
start_subscriptions(Reporter, Interval) ->
mongoose_metrics:start_global_metrics_subscriptions(Reporter, Interval),
lists:foreach(
fun(Host) ->
mongoose_metrics:start_host_metrics_subscriptions(Reporter, Host, Interval)
end, ?MYHOSTS);
start_subscriptions(Error, _Interval) ->
?ERROR_MSG("cannot start exometer reporter: ~p", [Error]).
end, ?MYHOSTS).
14 changes: 14 additions & 0 deletions rel/files/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
{lager_file_backend, [{file, "log/ejabberd.log"}, {level, info}, {size, 2097152}, {date, "$D0"}, {count, 5}]}
]}
]}
%{exometer, [
% {mongooseim_interval, 6000},
% {report, [
% {reporters, [
% {exometer_report_graphite, [
% {prefix, "mongosoeim"},
% {connect_timeout, 5000},
% {host, "127.0.0.1"},
% {port, 2003},
% {api_key, ""}
% ]}
% ]}
% ]}
% ]}
].

%% vim: filetype=erlang
1 change: 0 additions & 1 deletion rel/files/ejabberd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@
%%{sm_backend, {redis, [{pool_size, 3}, {worker_config, [{host, "localhost"}, {port, 6379}]}]}}.
{sm_backend, {{sm_backend}} }.

%{metrics_reporter, [{backend, graphite}, {interval, 5000}, {host, "127.0.0.1"}]}.

%%%. ==============
%%%' AUTHENTICATION
Expand Down

0 comments on commit fb550c4

Please sign in to comment.