Skip to content

Websocket Protocol

Mario Bielert edited this page Nov 27, 2018 · 1 revision

Definitions

  • All communication is done with JSON objects

Commands

These are RPC commands send from the client to the server

Subscribe

The client sends the server a list of metrics it likes to get live data. After this command, the server will send data messages in some interval.

{
  'function': 'subscribe',
  'metrics': [ METRICS ]
}

Where METRICS is the comma-separated list of metric ids.

Unsubscribe

The client notifies the server that it doesn't want to receive any further data messages.

Note: The client may disconnect without ever sending this command.

{
  'function': 'unsubscribe'
}

Messages

Data

After the subscribe command, the server will send these messages to the client in some interval.

Note: The server may not send any data message for a while if none of the subscribed metrics get an update

{
  'data': [ ENTRY,... ]
}

With ENTRY is:

{
  'id': 'METRIC',
  'ts': 'TIMESTAMP',
  'value': 'VALUE'
}

Error

The server may send this message at any time to indicate a problem.

{
  'error': 'MESSAGE'
}
Clone this wiki locally