Tech ONTAP Blogs
Tech ONTAP Blogs
In this blog we will be discussing how to use the Events REST API to view events on Active IQ Unified Manager by querying with the appropriate parameters.
By using the /management-server/events API, you can query the events in your data center, including historical data. Use the inbuilt filters, such as name, impact level, impact area, severity, state, resource name, and resource type, to view specific events. The resource type and area parameters return information about the storage object on which the event has occurred, and the impact area returns the information about the issue for which the event is raised, such as availability, capacity, configuration, security, protection, and performance. You can also use the event key to query the details of a specific event and run the next set of operations on the resources.
Now let's examine how we can views events on active IQ Unified Manager by querying with different parameters.
In cases where we have the event key (event.key) and event name (event.name), you can use the REST API in the following way to retrieve the event details
https://aiqum-server/api/management-server/events?key=94c8e9cd-5d6e-4f7f-8972-97d9a10234b4
https://aiqum-server/api/management-server/events?name=Volume%20Snapshot%20Reserve%20Space%20Full
It's also possible to query using the event key by using the /management-server/events/{key} API, you can query the events in your data center,
If you would like to view events about a particular cluster or clusters, you can go ahead and query using the cluster key (cluster.key), cluster UUID (cluster.uuid), or cluster Name cluster.name.
https://aiqum-server/api/management-server/events?cluster.uuid=be4339e5-b643-11ea-956c-00a098569e13
https://aiqum-server/api/management-server/events?cluster.name=AFF200
If you would like to view events pertaining to a particular Storage VM, you can go ahead and query using Storage VM key (svm.key), Storage VM UUID (svm.uuid) and Storage VM name (svm.name).
https://aiqum-server/api/management-server/events?svm.uuid=d0e4b703-93e9-11e9-ae68-00a098b1b4d1
https://aiqum-server/api/management-server/events?svm.name=OS_SOFTWARE
If you would like to view events pertaining to a particular storage node , you can go ahead and query using storage node name (node.name),storage node key (node.key) and node UUID (node.uuid)
https://aiqum-server/api/management-server/events?node.name=AFF200-01
You can go ahead and query using different severity levels (severity) like Warning, Error, Information, Critical.
You can go ahead and query using different current_state (current_state) like New, Obsolete Acknowledged, Resolved.
You can Query using different impact parameters
You can query events based on historical state, timestamp, user and cause ( history.state ,history.timestamp, history.user and history.cause).
Note:-“Filtering by the 'history.user' and 'history.cause' attribute is not allowed when the value for 'history.state' is 'new'" It is also possible query events based on a group (group) defined in Active IQ Unified Manager and also based on origin (origin).
Find events based on group based on Active IQ Unified Manager
Find events based on origin
https://aiqum-server/api/management-server/events?cluster.uuid=9fc58041-8e8b-11e9-ae68-00a098b1b4d1&origin=Active%20IQ%20Unified%20Manager
The other parameters to customize your search includes offset which enables us to set the start index for the entries to be returned, max_records to limit the number of records returned and Order_by to order results by specified field and optional [asc|desc] direction. Default direction is ‘asc’ for ascending.
The following sample program illustrates how to query events using different parameters with the /management-server/events API.
################################################################################
# Active IQ Unified Manager Event REST API Sample Scripts
#
# This script was developed by NetApp to help demonstrate NetApp
# technologies. This script is not officially supported as a
# standard NetApp product.
#
# Purpose: Script to Query events
#
# Usage: %> aiqum_events_script.py [
# --api <Cluster API>, --apiuser <API User>, --apipass <API Password> ]
#
################################################################################
import time
import base64
import argparse
import json
import requests
import sys
requests.packages.urllib3.disable_warnings()
def get_event():
HEADERS = {
'content-type': "application/json"
}
eventkeytype = input("Would you like to Query Events Using Event Key(y/n): ")
if eventkeytype == 'y':
eventkey = input("Enter the Event Key:-")
url = "https://"+api+"/api/management-server/events/" + eventkey
print()
print ("URL Deployed :{}".format(url))
print()
response = requests.get(url, auth=(apiuser, apipass), headers=HEADERS,verify=False)
print ("response :{}".format(response.json()))
sys.exit()
print()
url = "https://"+api+"/api/management-server/events?"
objecttype = input("Would you like to enter Cluster details, SVM details or Node details(cluster/node/svm): ")
if objecttype == 'cluster':
clustertype = input("Would you like to enter Cluster Name, UUID, Key (name/uuid/key): ")
if clustertype == 'name':
cluster_name = input(" Enter Cluster Name:- ")
url = url + "cluster.name=" + cluster_name
if clustertype == 'uuid':
cluster_uuid = input(" Enter Cluster UUID:- ")
url = url + "cluster.uuid=" + cluster_uuid
if clustertype == 'key':
cluster_key = input(" Enter Cluster Key:- ")
url = url + "cluster.key=" + cluster_key
if objecttype == 'node':
nodetype = input("Would you like to enter Node Name, UUID, Key (name/uuid/key): ")
if nodetype == 'name':
node_name = input(" Enter Node Name:- ")
url = url + "node.name=" + node_name
if nodetype == 'uuid':
node_uuid = input(" Enter Node UUID:- ")
url = url + "node.uuid=" + node_uuid
if nodetype == 'key':
node_key = input(" Enter Node Key:- ")
url = url + "node.key=" + node_key
if objecttype == 'svm':
svmtype = input("Would you like to enter SVM Name, UUID, Key (name/uuid/key): ")
if svmtype == 'name':
svm_name = input(" Enter SVM Name:- ")
url = url + "svm.name=" + svm_name
if svmtype == 'uuid':
svm_uuid = input(" Enter SVM UUID:- ")
url = url + "svm.uuid=" + svm_uuid
if svmtype == 'key':
svm_key = input(" Enter SVM Key:- ")
url = url + "svm.key=" + svm_key
severityswitch = input("Would you like to query by Severity(y/n): ")
if severityswitch == 'y':
severity_type = input("Enter the Severity Level (warning/error/information/critical):")
url = url + "&severity=" + severity_type
csswitch = input("Would you like to query by Current State(y/n): ")
if csswitch == 'y':
cs_type = input("Enter the Current State Level (new/obsolete/acknowledged/resolved):")
url = url + "¤t_state=" + cs_type
groupswitch = input("Would you like to query by Group(y/n): ")
if groupswitch == 'y':
group_type = input("Enter the Group Name:")
url = url + "&group=" + group_type
originswitch = input("Would you like to query by Origin(y/n): ")
if originswitch == 'y':
origin_type = input("Enter the Origin Name:")
url = url + "&origin=" + origin_type
impactlevelswitch = input("Would you like to query with Impact Level(y/n): ")
if impactlevelswitch == 'y':
impactlevel = input("enter Impact Level (incident/risk/event/upgrade): ")
url = url + "&impact.level=" + impactlevel
impactareaswitch = input("Would you like to query with Impact Area(y/n): ")
if impactareaswitch == 'y':
impactarea = input("Would you like to enter Impact Area (availability/capacity/configuration/performance/protection/security): ")
url = url + "&impact.area=" + impactarea
impactrtswitch = input("Would you like to query with Impact Resource Type(y/n): ")
if impactrtswitch == 'y':
impactrt = input("Would you like to enter Impact Resource Type (cluster/vserver/aggregate/volume): ")
url = url + "&impact.resource_type=" + impactrt
historyswitch = input("Would you like to query with History Type(y/n): ")
if historyswitch == 'y':
historytype = input("Would you like to enter History State, TimeStamp, User or Cause (state/time/user/cause): ")
if historytype == 'state':
historystate = input(" Enter History State:- ")
url = url + "history.state=" + historystate
if historytype == 'time':
historytime = input(" Enter History TimeStamp (2021-01-11T14%3A17%3A05.696%2B05%3A30):- ")
url = url + "history.timestamp=" + historytime
if historytype == 'user':
historyuser = input(" Enter History User:- ")
url = url + "history.user=" + historyuser
if historytype == 'cause':
historycause = input(" Enter History Cause:- ")
url = url + "history.cause=" + historycause
print()
print ("URL Deployed :{}".format(url))
print()
response = requests.get(url, auth=(apiuser, apipass), headers=HEADERS,verify=False)
print ("response :{}".format(response.json()))
return
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Passing variables to the program')
parser.add_argument('-api','--api', help='API server IP:port',dest='api',required=True)
parser.add_argument('-apiuser','--apiuser', help='Add APIServer Username',dest='apiuser',required=True)
parser.add_argument('-apipass','--apipass', help='Add APIServer Password',dest='apipass',required=True)
globals().update(vars(parser.parse_args()))
get_event()
print ("Script Complete")
Try it out!
Try out the /management-server/events API to query the events according to your requirements. Please let us know if you have any questions about this subject.