Marathon AppCop - Marathon applications law enforcement.
In large Mesos deployments there could be thousands of applications running and deploying every day. Sometimes they happen to be broken, forgotten and unmaintained which could exert pressure on cluster in numerous ways.
To address that AppCop clears Marathon from broken application deployments.
How it works
AppCop takes information provided by the Marathon event-stream
related to applications failures and scales them down.
Based on Marathon events (TASK_KILL, TASK_FAIL, TASK_FINISHED), AppCop is building score registry for each application event emited. Each score is incremented by each app event, so if events related to failures are comming it is constantly raising. When application passes treshold, then AppCop scales application one instance down forcefully and put appcop label in app definition. After that, score for this application is reset. When there is only one instance, then and score is pass theshold then application is suspended. Scores are periodically reset.
AppCop is periodically fetching applications and groups from Marathon. When application is suspended or group is empty for long (configurable) time then it is deleted.
AppCop provides set of standard system metrics as well as application based metrics.
System Metrics -
AppCop specific telemetry (e.g - queue Size, Event delays etc). Location equals,
Applications Metrics - Applications telemetry calculated based on events provided by marathon
(like: task_killed, task_finished counters). Location equals,
Please note the existance of
appid-prefix config option, if set, removes matching string from
application id when it comes to metric publication. For example, assumming
appid-prefix = com.example. appID = com.example.exampleapp
your applications metric will be placed under:
Installing from source code
To simply compile and run the source code:
go run main.go [options]
To run the tests:
To build the binary:
To build deb package:
Check dist/ dir.
AppCcop should be installed on all Marathon masters.
The event subscription should be set to
localhost to reduce network traffic.
Please refer to options section for more.
AppCop is using
Marathon labels to communicate actions or to tune execution logic.
||r||When AppCop encounters this label in app definition, treats it as immune to all penalties (excused from all criminal acts on cluster). Use this feature wisely, because if applied to often it could defeat whole purpose for using AppCop|
r - label is taken from app definition, not altered,
w - label is manipulated by
|config-file||Path to a JSON file to read configuration from. Note: Will override options set earlier on the command line|
|event-stream-location||/v2/events||Get events from this stream|
|my-leader||marathon-dev||My leader, when Marathon /v2/leader endpoint return the same string as this one, make subscription to event stream and launch jobs.|
||Size of events queue|
||Accept connections at this address|
|log-file||Save logs to file (e.g.:
||Log format: JSON, text|
||Log level: panic, fatal, error, warn, info or debug|
|marathon-password||Marathon password for basic auth|
||Marathon protocol (http or https)|
||Verify certificates when connecting via SSL|
||Time limit for requests made by the Marathon HTTP client. A timeout of zero means no timeout|
|appid-prefix||Prefix common to all fully qualified application ID's. Remove this preffix from applications id's ([Metric Types](#metric types))|
|marathon-username||Marathon username for basic auth|
||Score for application to scale it one instance down|
||How many scale down actions to commit in one scaling down iteration|
||Interval for updating app scores|
||How often collected scores are reset|
||How often collected scores are compared against scale-down-score|
||Metrics reporting interval|
|metrics-location||Graphite URL (used when metrics-target is set to graphite)|
||Metrics prefix (default is resolved to .<app_name>|
||System specific metrics. Append to metric-prefix|
||Applications specific metrics. Appended to metric-prefix|
||Metrics destination stdout or graphite (empty string disables metrics)|
||Number of concurrent workers processing events|
||Enable garbage collecting of Marathon, old suspended applications will be deleted|
||How long application should be suspended before deleting it|
||Marathon GC interval|
||Delete only applications suspended by AppCop|
||Perform a trial run with no changes made to marathon|
||healthcheck - returns