Developer Community

Reply
Highlighted
Occasional Contributor II

Aruba Central API Endpoint to get Alerts

Hei All,

 

I'm trying to find the endpoint which will list alerts. Here's a pic from Aruba Central.

 

Screenshot 2020-02-25 at 21.02.55.png

It would seem that I can get Events from 

"/monitoring/v1/events"

But these do not seem to correlate with the list of 7 alerts I get when I click on Alerts or Major in the above picture. For example, I have a Major alert for "new AP detected" which occurred on Feb 20th, 2020.

 

If I call the following method, I get 13 results, but none of them are for a "new AP detected" event. In fact, they're all for:

Station 30:24:32:ce:90:7d is black listed because 

```python

start = int(datetime(2020, 2, 20).timestamp())
stop = int(datetime(2020, 2, 21).timestamp())


def get_events(params: Dict, host: str) -> Union[Response, bool]:
url = host + "/monitoring/v1/events"

# params["limit"] = 20
# params["offset"] = 0
params["level"] = "major"
params["from_timestamp"] = start
params["to_timstamp"] = stop

response = httpx.get(url, params=params)
if response.status_code != 200:
print(response.content)
return response

```

 Anyone got any ideas where I'm going wrong?

 

Cheers,

 

Conor


Accepted Solutions
Highlighted
Aruba Employee

Re: Aruba Central API Endpoint to get Alerts

Hi Conor
I see that the endpoint you are using will not get you the information about the alerts as you desire. When working with alerts you will have multiple options to receive notifications of those alerts.

1) You can click on the "Alerts & Events" on the network launcher homepage, which will allow you to configure each alert the way you want:

  • Either using Webhooks, or
  • Email Notification

2) You can also use APIs in the notification container.

  • When you get to the API swagger page, select notification from the drop down 
  • Probably for your use case, the APIs that might come in handy are: 
    a) Types of notifications: GET /central/v1/notifications/types
    b) Configure Notifications/Alerts: POST /central/v1/notifications/settings
    c) Get a list of notifications: GET /central/v1/notifications
  • You can make use of other endpoints in that container according to your use case

Hope this helps. Let me know if I can help you with anything else.


Regards,

Jay

 

View solution in original post


All Replies
Highlighted
Aruba Employee

Re: Aruba Central API Endpoint to get Alerts

Hi Conor
I see that the endpoint you are using will not get you the information about the alerts as you desire. When working with alerts you will have multiple options to receive notifications of those alerts.

1) You can click on the "Alerts & Events" on the network launcher homepage, which will allow you to configure each alert the way you want:

  • Either using Webhooks, or
  • Email Notification

2) You can also use APIs in the notification container.

  • When you get to the API swagger page, select notification from the drop down 
  • Probably for your use case, the APIs that might come in handy are: 
    a) Types of notifications: GET /central/v1/notifications/types
    b) Configure Notifications/Alerts: POST /central/v1/notifications/settings
    c) Get a list of notifications: GET /central/v1/notifications
  • You can make use of other endpoints in that container according to your use case

Hope this helps. Let me know if I can help you with anything else.


Regards,

Jay

 

View solution in original post

Highlighted
Occasional Contributor II

Re: Aruba Central API Endpoint to get Alerts

Hi Jay,

 

Wonderful, thank you, the endpoint for Notifications is exactly what I was looking for!

 

Cheers,


Conor

Highlighted
Occasional Contributor II

Re: Aruba Central API Endpoint to get Alerts

**test

 

Hi Jay,

 

A follow up question if I may. What is the default timeframe for a request to GET /central/v1/notifications ?

 

As an example, I have two alerts with a severity level of Major in my default group. One of these occurred on the 20th February.

 

If I make a request to GET /central/v1/notifications with no other parameters than the token, I get no results, just an empty list. Likewise, if I only specify a severity level parameter = {"level": "Major"}, I get no results, just an empty list.

{
"count": 0,
"notifications": []
}

 

But, if I make a request with the following parameters:

{

"access_token": "my_token",

"from_timestamp: my_start_time,

"to_timestamp: my_stop_time,

}

Where start and stop are the 19th Feb and the 21st Feb, then I get the correct alert in the results.

{
"count": 1,
"notifications": [
{
"acknowledged": false,
"created_timestamp": 1582194484,
"description": "New AP with Name removed and MAC address removed detected, Group:default",
"group_name": "default",
"id": "removed",
"labels": [],
"severity": "Major",
"state": "Open",
"timestamp": 1582194484,
"type": "New AP detected"
}
]
}

So my question is, what is the default timeframe that the API returns results for when queried without timestamp parameters?

 

Cheers,


Conor

 

P.S. It would be fantastic if we could use Markdown in this forum. Would make writing code snippets so much nicer, both for author and reader. Is there a way I could suggest this to Aruba Airheads?

Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: