TD-178: Add Prometheus (#6)

This commit is contained in:
ndiezel0 2022-02-16 11:27:13 +03:00 committed by GitHub
parent 1f526eb70e
commit 5479ffa917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View File

@ -50,7 +50,6 @@ wc-shell: dev-image
wc-%: dev-image
$(DOCKER_RUN) $(DEV_IMAGE_TAG) make $*
# TODO docker compose down doesn't work yet
wdeps-shell: dev-image
$(DOCKERCOMPOSE_RUN) $(TEST_CONTAINER_NAME) su; \
$(DOCKERCOMPOSE_W_ENV) down

View File

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

View File

@ -81,6 +81,12 @@
{profiles, [
{prod, [
{deps, [
%% NOTE
%% Because of a dependency conflict, prometheus libs are only included in production build for now
%% https://github.com/project-fifo/rebar3_lint/issues/42
%% https://github.com/valitydev/hellgate/pull/2/commits/884724c1799703cee4d1033850fe32c17f986d9e
{prometheus, "4.8.1"},
{prometheus_cowboy, "0.1.8"},
% Introspect a node running in production
{recon, "2.5.2"},
{logger_logstash_formatter,
@ -99,6 +105,8 @@
{tools, load},
% logger formatter
{logger_logstash_formatter, load},
prometheus,
prometheus_cowboy,
token_keeper
]},
{sys_config, "./config/sys.config"},

View File

@ -43,6 +43,10 @@ init([]) ->
TokenBlacklistSpec = tk_blacklist:child_spec(genlib_app:env(?MODULE, blacklist, #{})),
TokensSpecs = tk_token:child_specs(genlib_app:env(?MODULE, tokens, #{})),
StoragesSpecs = tk_storage:child_specs(genlib_app:env(?MODULE, storages, #{})),
AdditionalRoutes = [
get_prometheus_route(),
get_health_route()
],
HandlerChildSpec = woody_server:child_spec(
?MODULE,
#{
@ -53,7 +57,7 @@ init([]) ->
shutdown_timeout => get_shutdown_timeout(),
event_handler => EventHandlers,
handlers => get_woody_handlers(AuditPulse),
additional_routes => [get_health_route() | get_machinegun_processor_routes(EventHandlers)]
additional_routes => AdditionalRoutes ++ get_machinegun_processor_routes(EventHandlers)
}
),
{ok, {
@ -147,3 +151,7 @@ get_audit_specs() ->
disable ->
{[], []}
end.
-spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}.
get_prometheus_route() ->
{"/metrics/[:registry]", prometheus_cowboy2_handler, []}.