marathon icon indicating copy to clipboard operation
marathon copied to clipboard

Improve format of events on the event bus

Open guenter opened this issue 12 years ago • 12 comments

The format of the events on the event bus is inconsistent, and a consumer needs to maintain a significant amount of state to make it useful. Let's track suggestions for a redesigned event bus here.

guenter avatar Jul 02 '14 23:07 guenter

See also #162

ConnorDoyle avatar Jul 02 '14 23:07 ConnorDoyle

See also the marathon-logger project. It presents a bounded buffer for events, presumably to promote statelessness in consumers of event bus output.

ConnorDoyle avatar Jul 02 '14 23:07 ConnorDoyle

Biggest problem I've encountered is matching taskIds to applications. Right now I have to do string matching against the taskId to guess what the app id is. Would be great to have app id as part of every task event.

mcculloughsean avatar Jul 08 '14 20:07 mcculloughsean

Some of the items I have been thinking about and would like to share are below, this is by no means meant as a proposal but more to serve as a point to begin a wider conversation related to the notifications system. It may be this is more detail than is desired to be added to this tool; however these are things I am considering when planning how I will implement Marathon in my environment.

Headers

I would propose there exist at minimum the following header:

x-mesosphere-marathon-event-type This header would serve to identify the event time, additionally it may be of benefit to employ a content negotiation aspect to this using Content-Type: application/vnd.mesosphere.marathon.{event_type}-v2+json this would serve to facilitate both content negotiation and event recognition.

see: http://tools.ietf.org/html/rfc4288#section-3.2

x-mesosphere-marathon-message-id Messages should provide a unique ID to ensure the uniqueness of messages in the event a dependant system may receive the same message more than once.

x-mesosphere-marathon-application-id The id of the deployed application the event is related to, this provides a means by which a recieving entity may choose to opt out of an event message prior to parsing/processing the payload.

x-mesosphere-marathon-event-version I may also be beneficial to provide the version of the event itself in the headers.

Message Payload

At this time I have little comments to offer on message payload with the exception I believe there may be value in a property i.e. _rel, $rel, uri or simply rely on the URI itself as the ID which would provide direct discovery of the application endpoint itself example: http://my.marathon.local:8080/v2/apps/mesos-chronos

{
    "id": "http://my.marathon.local:8080/v2/apps/mesos-chronos",
    "message-id": "00000-0000-00000-00000-00001"
    "event_type": ":event_type"
    ...
}

Message Types:

It is my recommendation that these be a short list of times for instance: - mesosphere-alarm would consist of health checks up, down and also reflect such mesos related information like LOST, FAILED, etc... These sub-types perhaps should be namespaced:

  - MESOS_TASK_LOST
  - MESOS_TASK_FAILED
  - MESOS_TASK_RUNNING
  - MARATHON_HEALTH_FAILED
  - MARATHON_HEALTH_PASS

Another consideration might be to support sending multiple messages in a single request should there be a queue of messages that require being sent:


[
    {
        "$rel": "http://my.marathon.local:8080/v2/apps/mesos-chronos",
        "id": "mesos-chronos",
        "message-id": "00000-0000-00000-00000-00001"
        "event_type": "MARATHON_HEALTH_FAILED"
        ...
    },
    {
        "$rel": "http://my.marathon.local:8080/v2/apps/mesos-chronos",
        "id": "mesos-chronos",
        "message-id": "00000-0000-00000-00000-00002"
        "event_type": "MESOS_TASK_LOST"
        ...
    }
]

Cryptographic Signature

I would also propose the addition of a signing step to the event submission process. To facilitate this allow for the configuration of a specific private key to the marathon process or the use of a randomly generated key are process start. This public key for signature would be made available at a url in the mesos process i.e. http://my.marathon.local:8080/signing_key.pem Subsequently all message signed would them provide the URL and required signing details as part of its message payload. There are more than one method of performing this goal, it is not my to recommend a specific one with these comments.

As well as support for a messages log to file and or stdout/stderr

Modularity for future additions

Additional consideration to facilitate all message payload to be wrapped by a standard parent document that would serve to describe such details at the transport level that may be required for future development of listeners. Examples may include SMS transport details, message queue information as well as the non-payload information such as the signature details, etc...

Creating a materialized document similar to:


{
    "signature": "ABCDEF0123456789",
    "signing-key": "http://my.marathon.local:8080/key.pem",
    "x-mesosphere-message-id": "00000-0000-00000-00000-00001",
    "x-mesosphere-marathon-event-type": "notification",
    "payload": [
        {
            "$rel": "http://my.marathon.local:8080/v2/apps/mesos-chronos",
            "id": "mesos-chronos",
            "event_type": "MARATHON_HEALTH_FAILED"
            ...
        },
        {
            "$rel": "http://my.marathon.local:8080/v2/apps/mesos-chronos",
            "id": "mesos-chronos",
            "event_type": "MESOS_TASK_LOST"
            ...
        }
    ]
}

Endpoints and Endpoint registration:

It may also be of benefit to see the event system become more extensible with avenues allowing for message queue types, email and other plugins being easily created and added. Another item to consider is the ability to register endpoints at runtime via the API without the need to add startup options to enable other event types.

zircote avatar Jul 25 '14 14:07 zircote

We need to have a way to have a client register for specific events. The number events that marathon produces can be large. A client (like an HAProxy bridge) only needs a couple events. It has to filter or ignore a number of events. By filter at the marathon process, the amount of network traffic will be greatly reduced.

kensipe avatar Sep 03 '14 22:09 kensipe

See also #654 and #162

ConnorDoyle avatar Oct 07 '14 06:10 ConnorDoyle

There is a need to log the event messages being sent and to whom to enable efficient debugging. Perhaps there is an option available today that I have missed so far.

ZiaBhatti avatar Oct 07 '14 07:10 ZiaBhatti

We should also ping the authors of Bamboo (an event bus consumer) to minimize breakage on this.

ConnorDoyle avatar Oct 07 '14 22:10 ConnorDoyle

I met one of the authors at the London meetup. I can see if I can reach out to him.

kensipe avatar Oct 07 '14 22:10 kensipe

The event firing frequency is too high. The event appear to fire on every task sync. If you have 10 task running then 10 events fire within every task-sync cycle even when nothing has changed. This simply does not scale. I am playing with bamboo and it tries to absorb these events without kicking off a new haproxy config.

ZiaBhatti avatar Oct 08 '14 01:10 ZiaBhatti

Related to https://github.com/mesosphere/marathon/issues/4947

janisz avatar Feb 25 '17 21:02 janisz

Note: This issue has been migrated to https://jira.mesosphere.com/browse/MARATHON-3700. For more information see https://groups.google.com/forum/#!topic/marathon-framework/khtvf-ifnp8.

meichstedt avatar Mar 07 '17 13:03 meichstedt