Alert policy creation and management endpoints in the REST API

Create and manage alerts policies that are used to generate events from the logs.

POST/policies
Request URL
/logs-service/api/v1.0/logs/policies
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>


Example request body

{
	"name": "Alert policy",
	"description": "Dummy description",
	"selection_criteria": "( Exception Equals 'NullPointer' )",
	"configurations": [{
		"name": "Alert_policy",
		"type": "ALERT",
		"details": {
			"groupBy": ["hostName"],
			"time_window": {
				"duration": "1",
				"unit": "MINUTES"
			},
			"conditionals": [{
					"count": "2",
					"severity": "MAJOR"
				},
				{
					"count": "5",
					"severity": "CRITICAL"
				}
			],
			"destination": {
				"type": "BHOM_EVENT",
				"details": {
					"class": "LOGALERT_EV",
					"source_hostname": "$.hostName",
					"msg": "Async Alert %msg% has been generated with severity %severity%",
					"additional_params": {
						"service_name": "logs-alert-service",
						"location": "$.location"
					}
				}
			}
		},
		"display_order": 1
	}],
	"enabled": true,
	"execution_order": 1
}


Response codes

CodeDescription
201

Alert policy is created successfully. Returns the alert policy ID in the payload.

400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
415Incorrect request format. Ensure that the request format is JSON.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

PUT/policies/{id}
Request URL
/logs-service/api/v1.0/logs/policies/{id}
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies/a00a0a00-a000-00a0-a000-0a000aa0a0a0
Request Header
Content-Type: application/json 
Authorization: Bearer <JWT_token>


Parameter details


Parameter NameValue TypeLocated InMandatoryDescription
idStringPathYesID of the alert policy.

Example request body

{
	"name": "Alert policy",
	"description": "Dummy description",
	"selection_criteria": "( Exception Equals 'NullPointer' )",
	"configurations": [{
		"name": "Alert_policy",
		"type": "ALERT",
		"details": {
			"groupBy": ["hostName"],
			"time_window": {
				"duration": "1",
				"unit": "MINUTES"
			},
			"conditionals": [{
					"count": "2",
					"severity": "MAJOR"
				},
				{
					"count": "5",
					"severity": "CRITICAL"
				}
			],
			"destination": {
				"type": "BHOM_EVENT",
				"details": {
					"class": "LOGALERT_EV",
					"source_hostname": "$.hostName",
					"msg": "Async Alert %msg% has been generated with severity %severity%",
					"additional_params": {
						"service_name": "logs-alert-service",
						"location": "$.location"
					}
				}
			}
		},
		"display_order": 1
	}],
	"enabled": true,
	"execution_order": 1
}

Response codes

CodeDescription
200

Alert policy is updated successfully.

400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
404The alert policy ID is not found.
415Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

GET/policies/{id}
Request URL
/logs-service/api/v1.0/logs/policies/{ID}
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies/a00a0a00-a000-00a0-a000-0a000aa0a0a0/upload
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>


Parameter details


Parameter NameValue TypeLocated InMandatoryDescription
idStringPathYesID of the alert policy.

Example request body

{
  "id": "b00b0b00-b000-00b0-b000-0b000bb0a0b0",
  "name": "Alert Policy",
  "description": "Dummy description",
  "tenant_id": "111111",
  "selection_criteria": "( Exception Equals 'NullPointer' )",
  "configurations": [
    {
      "id": "a00a0a00-a000-00a0-a000-0a000aa0a0a0",
      "name": "Alert_Policy",
      "type": "ALERT",
      "details": {  
			"groupBy": ["hostName"],
			"time_window": {
				"duration": "1",
				"unit": "MINUTES"
			},
			"conditionals": [{
					"count": "2",
					"severity": "MAJOR"
				},
				{
					"count": "5",
					"severity": "CRITICAL"
				}
			],
			"destination": {
				"type": "BHOM_EVENT",
				"details": {
					"class": "LOGALERT_EV",
					"source_hostname": "$.hostName",
					"msg": "Async Alert %msg% has been generated with severity %severity%",
					"additional_params": {
						"service_name": "logs-alert-service",
						"location": "$.location"
					}
				}
			}
		},
       "created_by": "admin",
      "created_at": 1634993638251,
      "updated_by": "admin",
      "updated_at": 1634993638251,
      "display_order": 1
    }
  ],
  "created_by": "admin",
  "created_at": 1634993638251,
  "updated_by": "admin",
  "updated_at": 1634993638251,
  "enabled": true,
  "execution_order": 1
}


Response codes

CodeDescription
200

Alert policies returned successfully.

401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
404The alert policy ID is not found.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

POST/policies/search
Request URL
/logs-service/api/v1.0/logs/policies/search
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies/search
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>


Example request body

{
"page_index": 1,
"page_size": 100,
"search_string": "name = 'Alert_Policy' and enabled = true",
"sort_criteria": "name DESC, enabled ASC"
}


Response codes

CodeDescription
200

Policies are found. Returns details of the policies in the payload.

400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assined to you.
415Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

POST/policies/enable
Request URL
/logs-service/api/v1.0/logs/policies/enable
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies/enable
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>


Example request body

{
  "ids": [
    "a00a0a00-a000-00a0-a000-0a000aa0a0a0"
  ]
}


Response codes

CodeDescription
200

Alert policies are enabled successfully.

207Some alert policies are enabled. IDs of the policies that are not enabled are returned.
400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
415Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

POST/policies/disable
Request URL
/logs-service/api/v1.0/logs/policies/disable
Example request URL
https://HostA.bmc.com/logs-service/api/v1.0/logs/policies/disable
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>


Example request body

{
  "ids": [
    "a00a0a00-a000-00a0-a000-0a000aa0a0a0"
  ]
}


Response codes

CodeDescription
200

Alert policies are disabled successfully. 

207Some alert policies are disabled. IDs of the policies that are not disabled are returned.
400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
415Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct.
500

Unexpected condition encountered. Contact BMC Support.

Back to top

DELETE/policies
Request URL
 /logs-service/api/v1.0/logs/policies
Example request URL
 https://HostA.bmc.com/logs-service/api/v1.0/logs/policies
Request Header
Content-Type: application/json
Authorization: Bearer <JWT_token>

For instructions on obtaining the JWT token, see Access and authentication for the REST API. Open link .

Example request body

{
  "id": [
    "a00a0a00-a000-00a0-a000-0a000aa0a0a0"
  ]
}

Response codes

CodeDescription
200

Alert policies are deleted successfully.

207Some alert policies are deleted. IDs of the policies that are not deleted are returned.
400Error for invalid data. Check if all input values are valid. 
401

Authorization failure. Verify JWT.

403Permission denied. Verify the roles assigned to you.
415Incorrect request format. Ensure that the request format is JSON and alert policies IDs are correct.
500

Unexpected condition encountered. Contact BMC Support.

Back to top


Was this page helpful? Yes No Submitting... Thank you

Comments