Search documentation of macula

# macula_app_monitor (macula v0.44.2)

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_all_stats()

Get stats for all monitored applications

get_stats(PackageName)

Get monitoring stats for an application

is_quarantined(PackageName)

Check if an application is quarantined

kill_app(PackageName)

Kill an application

quarantine_app(PackageName)

Quarantine an application (stop and prevent restart)

restore_app(PackageName)

Restore a quarantined application

set_crash_threshold(PackageName, MaxCrashes, WindowSec)

Set crash threshold for an application

set_memory_limit(PackageName, LimitMB)

Set memory limit for an application

set_message_queue_limit(PackageName, Limit)

Set message queue limit for an application

start_link(Config)

Start the app monitor

start_monitoring(PackageName, Pid)

Start monitoring an application

stop_monitoring(PackageName)

Stop monitoring an application

throttle_app(PackageName)

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)