thefactory / marathon-logger

Event logging service for Mesos Marathon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event logging service for Marathon Mesos framework.

Overview

marathon-logger is a Marathon event subscriber that logs each event to a pluggable event store.

On launch, it registers itself with the Marathon server. On exit, it deregisters itself.

Usage

Installing the requirements

Unless using the Docker image, you'll need the flask and marathon Python packages:

pip install -r requirements.txt

Running the service

$ python marathon-logger.py -h
usage: marathon-logger.py [-h] -m MARATHON_URL -c CALLBACK_URL
                          [-e EVENT_STORE] [-p PORT]

Marathon Logging Service

optional arguments:
  -h, --help            show this help message and exit
  -m MARATHON_URL, --marathon-url MARATHON_URL
                        Marathon server URL (http[s]://<host>:<port>[<path>])
  -c CALLBACK_URL, --callback-url CALLBACK_URL
                        callback URL for this service
                        (http[s]://<host>:<port>[<path>]/events
  -e EVENT_STORE, --event-store EVENT_STORE
                        event store connection string (default: in-
                        memory://localhost/)
  -p PORT, --port PORT  Port to listen on (default: 5000)

To start marathon-logger, simply run marathon-logger.py and provide the URL of the Marathon server and the addressable callback URL of the service.

Example:

python marathon-logger.py \
    -m http://marathon.mycompany.com/ \
    -c http://marathon-logger.mycompany.com/events \
    -e in-memory://localhost/?max_length=1000

Running via Docker

marathon-logger is available from the Docker Hub at thefactory/marathon-logger:

docker run -P thefactory/marathon-logger \
    -m http://marathon.mycompany.com/ \
    -c http://marathon-logger.mycompany.com/events \
    -e in-memory://localhost/?max_length=1000

Retrieving events

Events are available via a HTTP GET to /events. Note: not available with the syslog store type

Example (using httpie):

$ http GET localhost:5000/events
HTTP/1.0 200 OK
Content-Length: 394
Content-Type: application/json
Date: Wed, 11 Jun 2014 16:47:43 GMT
Server: Werkzeug/0.9.6 Python/2.7.5

{
    "events": [
        {
            "appId": "myapp",
            "eventType": "status_update_event",
            "host": "mesos-slave1.mycompany.com",
            "ports": [
                31705
            ],
            "slaveId": "20140609-224851-3187802122-5050-1365-2",
            "taskId": "myapp_1-1402505159061",
            "taskStatus": "TASK_KILLED",
            "timestamp": "2014-06-11T16:47:17.850Z"
        }
    ]
}

Event Stores

In-Memory

Store up to max_length events in memory. Safe for multiple threads, but not for multiple processes.

Parameters:

  • max_length - [optional, default: 100] max number of events to store

Example connection string

in-memory://localhost/?max_length=1000

Syslog (UDP)

Forward events to a syslog server via UDP. This event store has no retrieval capability, so GET /events will always return zero results.

Example connection string:

syslog://localhost:514/

About

Event logging service for Mesos Marathon

License:MIT License


Languages

Language:Python 93.1%Language:Shell 6.9%