Creating and managing alert policies with REST APIs
Create and manage alerts policies that are used to generate events from the logs.
POST/policies
Create an alert policy
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
Code | Description |
---|---|
201 | Alert policy is created successfully. Returns the alert policy ID in the payload. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
415 | Incorrect request format. Ensure that the request format is JSON. |
500 | Unexpected condition encountered. Contact BMC Support. |
PUT/policies/{id}
Update an alert policy by ID
Authorization: Bearer <JWT_token>
Parameter details
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
Code | Description |
---|---|
200 | Alert policy is updated successfully. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
404 | The alert policy ID is not found. |
415 | Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct. |
500 | Unexpected condition encountered. Contact BMC Support. |
GET/policies/{id}
Get an alert policy by ID
Authorization: Bearer <JWT_token>
Parameter details
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
Code | Description |
---|---|
200 | Alert policies returned successfully. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
404 | The alert policy ID is not found. |
500 | Unexpected condition encountered. Contact BMC Support. |
POST/policies/search
Search alert policies
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
Code | Description |
---|---|
200 | Policies are found. Returns details of the policies in the payload. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assined to you. |
415 | Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct. |
500 | Unexpected condition encountered. Contact BMC Support. |
POST/policies/enable
Enable alert policies
Authorization: Bearer <JWT_token>
Example request body
"ids": [
"a00a0a00-a000-00a0-a000-0a000aa0a0a0"
]
}
Response codes
Code | Description |
---|---|
200 | Alert policies are enabled successfully. |
207 | Some alert policies are enabled. IDs of the policies that are not enabled are returned. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
415 | Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct. |
500 | Unexpected condition encountered. Contact BMC Support. |
POST/policies/disable
Disable alert policies
Authorization: Bearer <JWT_token>
Example request body
"ids": [
"a00a0a00-a000-00a0-a000-0a000aa0a0a0"
]
}
Response codes
Code | Description |
---|---|
200 | Alert policies are disabled successfully. |
207 | Some alert policies are disabled. IDs of the policies that are not disabled are returned. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
415 | Incorrect request format. Ensure that the request format is JSON and alert policy IDs are correct. |
500 | Unexpected condition encountered. Contact BMC Support. |
DELETE/policies
Delete alert policies
Authorization: Bearer <JWT_token>
For instructions on obtaining the JWT token, see Access and authentication for the REST API..
Example request body
"id": [
"a00a0a00-a000-00a0-a000-0a000aa0a0a0"
]
}
Response codes
Code | Description |
---|---|
200 | Alert policies are deleted successfully. |
207 | Some alert policies are deleted. IDs of the policies that are not deleted are returned. |
400 | Error for invalid data. Check if all input values are valid. |
401 | Authorization failure. Verify JWT. |
403 | Permission denied. Verify the roles assigned to you. |
415 | Incorrect request format. Ensure that the request format is JSON and alert policies IDs are correct. |
500 | Unexpected condition encountered. Contact BMC Support. |