Add prometeus (#27)

* Add prometeus

* Move metrics to management point

* Revert image upgrade

* Add missing rebar.lock
This commit is contained in:
Sergey Yelin 2020-10-26 16:52:55 +03:00 committed by GitHub
parent 9393b58856
commit df8a550af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 3 deletions

View File

@ -14,7 +14,9 @@
msgpack,
lib_combin,
jose,
cds_proto
cds_proto,
prometheus,
prometheus_cowboy
]},
{env, []},
{modules, []},

View File

@ -34,6 +34,7 @@ init([]) ->
{ok, IP} = inet:parse_address(application:get_env(kds, ip, "::")),
HealthCheck = genlib_app:env(?MODULE, health_check, #{}),
HealthRoute = erl_health_handle:get_route(enable_health_logging(HealthCheck)),
PrometeusRoute = get_prometheus_route(),
KeyringManagementService = woody_server:child_spec(
kds_thrift_management_service_sup,
#{
@ -46,7 +47,7 @@ init([]) ->
transport_opts => genlib_app:env(?MODULE, management_transport_opts, #{}),
protocol_opts => genlib_app:env(?MODULE, protocol_opts, #{}),
shutdown_timeout => genlib_app:env(?MODULE, shutdown_timeout, 0),
additional_routes => [HealthRoute]
additional_routes => [HealthRoute, PrometeusRoute]
}
),
KeyringStorageService = woody_server:child_spec(
@ -84,6 +85,10 @@ enable_health_logging(Check) ->
EvHandler = {erl_health_event_handler, []},
maps:map(fun(_, V = {_, _, _}) -> #{runner => V, event_handler => EvHandler} end, Check).
-spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}.
get_prometheus_route() ->
{"/metrics/[:registry]", prometheus_cowboy2_handler, []}.
%%
%% Application callbacks
%%

View File

@ -101,5 +101,9 @@
{snowflake, [
{max_backward_clock_moving, 1000}, % 1 second
{machine_id, hostname_hash}
]},
{prometheus, [
{collectors, [default]}
]}
].

View File

@ -23,6 +23,8 @@
{jose, "1.9.0"},
{recon , "2.3.2"},
{libdecaf, "1.0.0"},
{prometheus, "4.6.0"},
{prometheus_cowboy, "0.1.8"},
{shamir , {git, "git@github.com:rbkmoney/shamir.git" , {branch, master}}},
{woody , {git, "git@github.com:rbkmoney/woody_erlang.git" , {branch, master}}},
{logger_logstash_formatter, {git, "git@github.com:rbkmoney/logger_logstash_formatter.git", {branch, master}}},
@ -53,6 +55,7 @@
{vm_args, "./config/vm.args"},
{dev_mode, true},
{include_erts, false},
{include_src, false},
{extended_start_script, true}
]}.

View File

@ -1,5 +1,6 @@
{"1.1.0",
[{<<"base64url">>,{pkg,<<"base64url">>,<<"0.0.1">>},1},
[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2},
{<<"base64url">>,{pkg,<<"base64url">>,<<"0.0.1">>},1},
{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
{<<"cds_proto">>,
@ -54,6 +55,9 @@
{git,"git@github.com:seth/pooler.git",
{ref,"9c28fb479f9329e2a1644565a632bc222780f1b7"}},
0},
{<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.6.0">>},0},
{<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0},
{<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1},
{<<"proper">>,{pkg,<<"proper">>,<<"1.3.0">>},1},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},2},
{<<"recon">>,{pkg,<<"recon">>,<<"2.3.2">>},0},
@ -81,6 +85,7 @@
0}]}.
[
{pkg_hash,[
{<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>},
{<<"base64url">>, <<"36A90125F5948E3AFD7BE97662A1504B934DD5DAC78451CA6E9ABF85A10286BE">>},
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
{<<"cache">>, <<"3C11DBF4CD8FCD5787C95A5FB2A04038E3729CFCA0386016EEA8C953AB48A5AB">>},
@ -96,6 +101,9 @@
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"prometheus">>, <<"20510F381DB1CCAB818B4CF2FAC5FA6AB5CC91BC364A154399901C001465F46F">>},
{<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>},
{<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>},
{<<"proper">>, <<"C1ACD51C51DA17A2FE91D7A6FC6A0C25A6A9849D8DC77093533109D1218D8457">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
{<<"recon">>, <<"4444C879BE323B1B133EEC5241CB84BD3821EA194C740D75617E106BE4744318">>},