Subscribing to push notifications

Ops Center Analyzer Detail View REST API Reference Guide

Version
11.0.x
Audience
anonymous
Part Number
MK-99ANA004-10

You can subscribe to push notifications to receive alerts for the violations when they occur.

For push notifications, you must open the websocket connection between the client (the client used to invoke the REST API calls) and the Analyzer detail view, and send the list of alert IDs for which you want to receive notifications. The Analyzer detail view then starts sending the alerts for the violations over this connection until the connection is closed or terminated.

To subscribe to the push notifications, you must send the list of alert IDs to the Analyzer detail view (this is a one-time activity). This list of alert IDs cannot be changed later.

To change the subscription, you must stop the connection and reconnect using the updated list of alert IDs.

Push notifications are designed to send alerts for current violations over a websocket connection. If there is a connectivity issue between the websocket and the Analyzer detail view server, the Analyzer detail view server does not resume from where it left off. Instead, it starts sending a current set of alerts. You can get the missing alerts using the getAlerts call.

Push notification API is only available over HTTPS in sync with the rest of the API.

Request line

The client opens the websocket connection with the given URL and authorization header.

wss://<hostname>:8443/pusher/alerts
Authorization:Basic XXXXXXXXX

Request example

{  
   "function":"subscribe",
   "alertIds":[  
      11232,
      31323,
      43134
   ]
}

Response examples

The following push message format in JSON is sent over the websocket connection. This JSON contains alert violation data for performance metrics.

[ 
   { 
      "id":"1",
      "name":"Production VMs High CPU Usage",
      "severity":"warning",
      "from":"20160401_235300",
      "to":"20160401_235700",
      "violations":{ 
         "vm#vm1234":[ 
            "20160401_235500",
            "20160401_235600",
            "20160401_235700"
         ]
      }
   }
]

The following push message format in JSON is sent over the websocket connection. This JSON contains alert violation data for configuration metrics.

[
   {
      "id":"31",
      "name":"vmware_test",
      "severity":"critical",
      "violations":{"vm#Test_192.168.144.140_2": ["20190314_143100"]},
      "Value":["POWERED_ON"]
   }
]

The response message where alert ID does not exist:

{
  "meta":{
    "code":"277",
    "failed":[
      {
        "id":3,
        "code":"FFFFFFFF",
        "message":"alert with id does not exists"
      }
    ]
  }
}

The response message where the alert ID is already subscribed:

{
  "meta":{
    "code":"277",
    "failed":[
      {
        "id":1,
        "code":"FFFFFFFE",
        "message":"current alert is already subscribed"
      }
    ]
  }
}

Further subscription calls are ignored after this stage.