Create a Notification Policy
To monitor operations with files and folders on Nutanix File Server, you should configure a notification policy for the related events.
Monitored Operations
The list of supported operations is provided in the table below. Your notification policy can include any of them.
To audit... | Operation name to specify at policy creation |
---|---|
Successful create operations | FILE_CREATE DIRECTORY_CREATE |
Successful read operations | FILE_READ |
Successful modify operations | FILE_WRITE RENAME SECURITY |
Successful delete operations | FILE_DELETE DIRECTORY_DELETE |
Failed read/modify/delete attempts* | FILE_OPEN |
* - Failed attempt to move/rename file are not audited.
Configuration Procedure
Notification policy creation procedure involves API requests usage. It is assumed that you have a good understanding of REST API concepts, as well as enough experience in working with JSON-formatted requests in any API client. To get acquainted with Nutanix REST API Explorer client, refer to Nutanix documentation.
To create a notification policy for Nutanix File Server via API:
-
Open the File Server REST API Explorer client using the following URL:
https://`<fileserver_ip>`:9440/api/nutanix/v3/api_explorer/index.html#/
here
<fileserver_ip>
- IP address of the Nutanix File Server to be audited.
If you select to launch the RestAPI Explorer from the Prism menu, the RestAPI Explorer for Prism client will be opened.
-
In the username and password fields, enter the credentials of the Create User Account to Access Nutanix REST API you have created.
-
Click Explore.
-
In the File Server REST API Explorer REST API client, locate the POST request for
notification_policies
:POST /notification_policies
-
In the request body, enter the following JSON-formatted structure:
{
"spec": {
"name": "<NAME_OF_NOTIFICATION_POLICY>",
"resources": {
"all_mount_targets" : true,
"protocol_type_list" : ["SMB"],
"file_operation_list" : [<LIST_OF_FILE_OPERATIONS>],
"partner_server_reference_list" : [{
"kind" : "partner_server",
"uuid" : "<UUID_OF_PARTNER_SERVER>"
}]
},
"description": "<optional_string>"
},
"api_version": "3.0",
"metadata": {
"kind": "notification_policy"
}
}
here:
"all_mount_targets" : true - instructs to notify on changes to all shares
"protocol_type_list" : ["SMB"] - instructs to track SMB shares (the only currently supported)
<NAME_OF_NOTIFICATION_POLICY>
– enter the name of notification policy you want to create
<UUID_OF_PARTNER_SERVER>
- enter the uuid
of
Configure Partner Server
<LIST_OF_FILE_OPERATIONS>
- enter the list of operations to be audited.
-
Send the request, clicking Try it out.
-
Get the response -
Response Code
should be 200. In the response body, locate theuuid
of the created notification policy. -
To check that a new policy was included in the list of existing policies, retrieve the list of policies, sending the POST request to the following endpoint:
POST /notification_policies/list
. The request body must be empty - for that, enter empty brackets as the value for get_entities_request parameter :{ }
Auditing Specific Folders
If you want to audit only the certain folders on Nutanix File Server (mount targets), then do the following:
- Retrieve the list of existing mount targets using the
mount_target POST /mount_targets/list
request with empty body, as described above. - In the response, locate the
uuids
of the target folders you want to audit. - In the notification policy creation request (described above) instead of
"all_mount_targets" : true
in the request body enter the following JSON-formatted structure:
"mount_target_reference_list": [
{
"kind" : "mount_target",
"uuid" : "<UUID_OF_MOUNT_TARGET1>"
},
{
"kind" : "mount_target",
"uuid" : "<UUID_OF_MOUNT_TARGET2>"
},
]
here:
<UUID_OF_MOUNT_TARGET>
– enter the uuid of target you want to audit.
Example
The JSON-formatted structure below is an example of the request body that can be used to create a notification policy named MOUNT_POINT_POLICY to audit the mount a share on Nutanix File Server with the uuid=378896fd-e829-4869-84a2-6c29268acfff. The following operations will be audited:
- "FILE_READ",
- "FILE_CREATE",
- "FILE_DELETE",
- "DIRECTORY_CREATE",
- "DIRECTORY_DELETE",
- "FILE_WRITE",
- "RENAME",
- "SECURITY",
- "FILE_OPEN"
JSON structure is as follows:
{
"spec": {
"name": "MOUNT_POINT_POLICY ",
"resources": {
"mount_target_reference_list": [
{
"kind" : "mount_target",
"uuid" : "378896fd-e829-4869-84a2-6c29268acfff”
}
],
"protocol_type_list" : ["SMB"],
"file_operation_list" :[
"FILE_READ",
"FILE_CREATE",
"FILE_DELETE",
"DIRECTORY_CREATE",
"DIRECTORY_DELETE",
"FILE_WRITE",
"RENAME",
"SECURITY",
"FILE_OPEN"
],
"partner_server_reference_list" : [
{
"kind" : "partner_server",
"uuid" : " d0bfb952-924b-459e-bd32-44c8b5a62838"
}
]
},
"description": "<optional_string>"
},
"api_version": "3.0",
"metadata": {
"kind": "notification_policy"
}
}