mirror of
https://github.com/valitydev/token-keeper.git
synced 2024-11-06 02:15:21 +00:00
TD-178: Add Prometheus (#6)
This commit is contained in:
parent
1f526eb70e
commit
5479ffa917
1
Makefile
1
Makefile
@ -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
|
||||
|
@ -203,5 +203,9 @@
|
||||
% 1 second
|
||||
{max_backward_clock_moving, 1000}
|
||||
% {machine_id, hostname_hash}
|
||||
]},
|
||||
|
||||
{prometheus, [
|
||||
{collectors, [default]}
|
||||
]}
|
||||
].
|
||||
|
@ -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"},
|
||||
|
@ -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, []}.
|
||||
|
Loading…
Reference in New Issue
Block a user