POST Alerts

POST Alerts

Create a new alert by given parameters. The 'name' parameter is mandatory. There are some optional parameters as well, but some of them could be required in specific combination with other parameters. For example:

  • When the field 'emailEnabled' is set to 'true' then at least one email address should be specified in the 'emails' field.
  • When the field 'webhookEnabled' is set to 'true' then at least one URL should be specified in the 'webhookURLs' field.
  • When the field 'vcopsEnabled' is set to 'true' then 'vcopsResourceKindKey' field should be specified.
Request
URI
POST
https://{api_host}/api/v1/alerts
COPY
Request Body
alerts.post.request of type(s) application/json
Optional
{
    "name": "My Alert",
    "info": "This is an example of a rate based alert",
    "recommendation": "Some text for recommendation",
    "emailEnabled": true,
    "emails": "[email protected], [email protected]",
    "webhookEnabled": true,
    "webhookURLs": "http://username:[email protected]/webhook1 http://example.com/webhook2",
    "vcopsEnabled": true,
    "vcopsCriticality": "none",
    "vcopsResourceKindKey": "resourceName=test-vsan-template&adapterKindKey=VMWARE&resourceKindKey=VirtualMachine&identifiers=VMEntityName::test-vsan-template$$VMEntityObjectID::vm-107$$VMEntityVCID::94a1a7ea-ff03-4c18-827a-413998b7308c",
    "autoClearAlertAfterTimeout": false,
    "alertType": "RATE_BASED",
    "hitCount": 4,
    "searchPeriod": 300000,
    "hitOperator": "GREATER_THAN",
    "chartQuery": "{\"query\":\"alert\",\"startTimeMillis\":1500451917374,\"endTimeMillis\":1500532872702,\"piqlFunctionGroups\":[{\"functions\":[{\"label\":\"Count\",\"value\":\"COUNT\",\"requiresField\":false,\"numericOnly\":false}],\"field\":null}],\"dateFilterPreset\":\"LAST_5_MINUTES\",\"shouldGroupByTime\":true,\"eventSortOrder\":\"DESC\",\"summarySortOrder\":\"DESC\",\"compareQueryOrderBy\":\"TREND\",\"compareQuerySortOrder\":\"DESC\",\"compareQueryOptions\":null,\"messageViewType\":\"EVENTS\",\"constraintToggle\":\"ALL\",\"piqlFunction\":{\"label\":\"Count\",\"value\":\"COUNT\",\"requiresField\":false,\"numericOnly\":false},\"piqlFunctionField\":null,\"fieldConstraints\":[],\"supplementalConstraints\":[],\"groupByFields\":[],\"extractedFields\":[]}"
}
Authentication
This operation uses the following authentication methods.
Responses
200
Operation doesn't return any data structure

Response Headers

string
Warning

Additional information about the life-cycle status of the API.

string
VMware-LI-API-Status

Indicates the life-cycle status of the API.


201

Created a new alert with the provided data

{
    "id": "fc7bfcac-200c-4840-b349-b885338f03d1",
    "enabled": true,
    "emailEnabled": true,
    "vcopsEnabled": true,
    "alertType": "RATE_BASED",
    "name": "Hello Alert",
    "hitCount": 2,
    "searchPeriod": 300000,
    "searchInterval": 60000,
    "emails": "[email protected], [email protected]",
    "info": "This is an example of a rate based alert",
    "vcopsResourceName": "local-li-wdc-li1-04",
    "vcopsCriticality": "immediate",
    "lastRanAt": 1497017941283,
    "lastRanAtString": "2017-06-09 18:19:01.283 GMT+04:00",
    "nextRunAt": 1497018241283,
    "nextRunAtString": "2017-06-09 18:24:01.283 GMT+04:00",
    "runCount": 7,
    "lastRunTime": 800,
    "totalRunTime": 946,
    "lastHitTimestamp": 1497017922145,
    "lastHitTimestampString": "2017-06-09 18:18:42.145 GMT+04:00",
    "ownerUuid": "1f024658-8b93-4f45-ae59-4657f96a5450",
    "webhookEnabled": true,
    "webhookURLs": "http://example.com/webhook1 http://example.com/webhook2",
    "autoClearAlertAfterTimeout": false,
    "chartQuery": "{\"query\":\"\",\"startTimeMillis\":1506417301511,\"endTimeMillis\":1506423141233,\"piqlFunctionGroups\":[{\"functions\":[{\"label\":\"Count\",\"value\":\"COUNT\",\"requiresField\":false,\"numericOnly\":false}],\"field\":null}],\"dateFilterPreset\":\"LAST_5_MINUTES\",\"shouldGroupByTime\":true,\"eventSortOrder\":\"DESC\",\"summarySortOrder\":\"DESC\",\"compareQueryOrderBy\":\"TREND\",\"compareQuerySortOrder\":\"DESC\",\"compareQueryOptions\":null,\"messageViewType\":\"EVENTS\",\"constraintToggle\":\"ALL\",\"piqlFunction\":{\"label\":\"Count\",\"value\":\"COUNT\",\"requiresField\":false,\"numericOnly\":false},\"piqlFunctionField\":null,\"fieldConstraints\":[{\"internalName\":\"ibadax3fpbpwm2lfnrsf643bl5stezk7onugc4tfmq000000\",\"operator\":\"CONTAINS\",\"value\":\"lang\"},{\"internalName\":\"ibadgns7mm4domrsgq4dkllgmvstcljrgfsteljygnrdoljsgbrtszbqgq3win3bg5sxqx3gnfwgkzc7onqv6zjsmvpw433oonugc4tfmrpwe6k7mfsg22lo\",\"operator\":\"CONTAINS\",\"value\":\"run\"}],\"supplementalConstraints\":[],\"group"
}
string As ^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$
id
Optional

id

boolean
enabled
Optional

enabled

string
alertType
Optional

alertType

Possible values are : RATE_BASED, RATE_BASED_WITH_GROUPS, NEW_EVENT_TYPE,
string
name
Optional

name

integer
hitCount
Optional
Constraints: minimum: 0 maximum: 100000

hitCount

integer
searchPeriod
Optional
Constraints: minimum: 60000

searchPeriod

integer
searchInterval
Optional
Constraints: minimum: 60000

searchInterval

string
info
Optional

info

boolean
emailEnabled
Optional

emailEnabled

string
emails
Optional

A comma-separated list of email addresses

boolean
vcopsEnabled
Optional

vcopsEnabled

string
vcopsResourceName
Optional

vcopsResourceName

string
vcopsCriticality
Optional

vcopsCriticality

Possible values are : none, information, warning, immediate, critical,
boolean
webhookEnabled
Optional

webhookEnabled

string
webhookURLs
Optional

A space-separated list of URLs

integer
lastRanAt
Optional

lastRanAt

string
lastRanAtString
Optional

lastRanAtString

integer
nextRunAt
Optional

nextRunAt

string
nextRanAtString
Optional

nextRanAtString

integer
runCount
Optional

runCount

integer
lastRunTime
Optional

lastRunTime

integer
totalRunTime
Optional

totalRunTime

integer
lastHitTimestamp
Optional

lastHitTimestamp

string
lastHitTimestampString
Optional

lastHitTimestampString

string As ^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$
ownerUuid
Optional

ownerUuid

boolean
autoClearAlertAfterTimeout
Optional

autoClearAlertAfterTimeout

string
chartQuery
Optional

A string of JSON format


400

Error trying to create an alert with incorrect parameters

{
    "errorMessage": "The 'name' field is required"
}
string
errorMessage
Optional

errorMessage


401

The request was refused because it lacks valid authentication credentials. This can happen if the Authorization header was missing, or if it contained an invalid session ID.

Obtain a new session ID and retry the request, or make an unauthenticated request without the Authorization header.

"Invalid session ID"

440

The request was refused because the session ID has expired. Obtain a new session ID from /api/v1/sessions.

"Login Timeout"

500

Internal error while processing the client request

Returns error of type(s) application/json
{
    "errorMessage": "The operation failed due to an internal error."
}
string
errorMessage
Required

A message describing the error.

string
errorCode
Optional

A code representing the type of error.

Possible values are : LIMIT_ERROR, FIELD_ERROR, TEST_ERROR, JSON_FORMAT_ERROR, LICENSE_ERROR, VSPHERE_INTEGRATION_ERROR, VROPS_INTEGRATION_ERROR, UPGRADE_ERROR, SEARCH_ERROR, AGENT_ERROR, RBAC_COMMON_ERROR, RBAC_USERS_ERROR, RBAC_GROUPS_ERROR, RBAC_ADGROUPS_ERROR, RBAC_DATASETS_ERROR, RBAC_VIDM_GROUPS_ERROR, RBAC_VIDB_GROUPS_ERROR, SECURITY_ERROR, DEPLOYMENT_ERROR, SUPPORT_BUNDLE_ERROR, LOAD_BALANCER_ERROR, VIDM_ERROR, VIDB_ERROR, QUERY_ERROR, SSL_CERTIFICATE_ERROR, PROXY_ERROR,
object
errorDetails
Optional

Dynamic error details, where the field name can vary depending on the request field and error code.


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '[{}]' https://{api_host}/api/v1/alerts