macula_app_monitor (macula v0.20.5)

View Source

Macula App Monitor

Runtime defense monitor for deployed applications: - Memory usage monitoring - Message queue monitoring - Crash rate detection - Throttle/Kill/Quarantine actions

Summary

Functions

Get stats for all monitored applications

Get monitoring stats for an application

Check if an application is quarantined

Kill an application

Quarantine an application (stop and prevent restart)

Restore a quarantined application

Set crash threshold for an application

Set memory limit for an application

Set message queue limit for an application

Start the app monitor

Start monitoring an application

Stop monitoring an application

Throttle an application (reduce priority)

Functions

get_all_stats()

-spec get_all_stats() -> #{binary() => map()}.

Get stats for all monitored applications

get_stats(PackageName)

-spec get_stats(PackageName :: binary()) ->
                   {ok,
                    #{memory_mb := non_neg_integer(),
                      message_queue := non_neg_integer(),
                      crash_count := non_neg_integer(),
                      status := atom()}} |
                   {error, not_found}.

Get monitoring stats for an application

is_quarantined(PackageName)

-spec is_quarantined(PackageName :: binary()) -> boolean().

Check if an application is quarantined

kill_app(PackageName)

-spec kill_app(PackageName :: binary()) -> ok | {error, term()}.

Kill an application

quarantine_app(PackageName)

-spec quarantine_app(PackageName :: binary()) -> ok | {error, term()}.

Quarantine an application (stop and prevent restart)

restore_app(PackageName)

-spec restore_app(PackageName :: binary()) -> ok | {error, term()}.

Restore a quarantined application

set_crash_threshold(PackageName, MaxCrashes, WindowSec)

-spec set_crash_threshold(PackageName :: binary(),
                          MaxCrashes :: pos_integer(),
                          WindowSec :: pos_integer()) ->
                             ok | {error, not_found}.

Set crash threshold for an application

set_memory_limit(PackageName, LimitMB)

-spec set_memory_limit(PackageName :: binary(), LimitMB :: pos_integer()) -> ok | {error, not_found}.

Set memory limit for an application

set_message_queue_limit(PackageName, Limit)

-spec set_message_queue_limit(PackageName :: binary(), Limit :: pos_integer()) ->
                                 ok | {error, not_found}.

Set message queue limit for an application

start_link(Config)

-spec start_link(Config :: map()) -> {ok, pid()} | {error, term()}.

Start the app monitor

start_monitoring(PackageName, Pid)

-spec start_monitoring(PackageName :: binary(), Pid :: pid()) -> ok.

Start monitoring an application

stop_monitoring(PackageName)

-spec stop_monitoring(PackageName :: binary()) -> ok.

Stop monitoring an application

throttle_app(PackageName)

-spec throttle_app(PackageName :: binary()) -> ok | {error, term()}.

Throttle an application (reduce priority)