Skip to main content

Contrail Analytics Streaming API

By October 24, 2015Analytics, Uncategorized

Contrail Analytics collects information from the various components of the system, and provides the visibility into flows, logs and UVEs that is needed to operate this system. This information is provided via a REST API, which can be used to build management and analytics applications and dashboards. The Contrail UI uses this REST API as well.

In addition to providing HTTP GET APIs (Operational State in the OpenContrail system: UVE – User Visible Entities through Analytics API) , we also provide a Streaming API for UVEs and Alerts. This is a very useful option for enabling rapid development of powerful and efficient applications on top of Contrail Analytics. Contrail Analytics Streaming API uses the Server-Sent Events EventSource API , which is standardized as part of HTML5.

See Contrail Analytics Streming API features in a demo:

[video_lightbox_youtube video_id=”h6GelebZo7A” width=”720″ height=”540″ auto_thumb=”1″]

API details

Two APIs are provided – one for alarms (read more about it in the detailed Contrail Alerts blogpost), and the other for entire UVE contents:

GET http://<analytics-ip>:<rest-api-port>/analytics/alarm-stream
GET http://<analytics-ip>:<rest-api-port>/analytics/uve-stream

Client may ask for a subset of updates using filters in URL parameters:
“tablefilt=,[…]” will provide updates for only the given UVE table types (e.g. control-node, virtual-machine etc.)

For uve-stream, we can further filter by UVE Content Structures:

Lets take an example.
We can ask got a stream of all bgp-peer UVE updates as follows:


First, we read all existing bgp-peer UVEs and report their contents. Then, we report updates. Continuous updates will be reported as the UVE is updated, until the user closes the connection. The data is reported with “key” , “type”, and “value”.

  • The “key” is the UVE Key.
  • The “type” is a UVE Content Structure. Multiple of these may be reported per UVE-Key. When any attribute under a Structure changes, the entire Structure is sent again. When the UVE is deleted, the streaming API will report the “key” with a “type” of null.
  • The “value” is a JSON object representing the contents (attributes) of the Structure above. When the Structure is deleted, the streaming API will report the “key” and Structure “type” with a value of null.

Lets take another example. We have an Analytics Node where the contrail-snmp-collector process has stopped. This will cause an alarm.
This is what we see in the alarm stream:


Keep the stream open. Now we repair the system by restarting the contrail-snmp-collector. The stream reports that the alarm has been deleted: