{tenantId}/metric-alerts
This API can be used to create alert definitions.
Generated accessToken required to have alerts:manage
scope to access this API and EVERYONE
Target level and CLIENT
provider.
Json key | Json Value Type | Description | accepted format | mandatory/optional |
---|---|---|---|---|
name | String | alert definition name, it should be unique across the client | String should not be null or empty | mandatory |
query | String | PromQL Query | String should not be null or empty | mandatory |
alertThresholdType | String | it indicates alerts threshold type | it should be STATIC_THRESHOLD | mandatory |
alertThresholdData | JSON Object | it contains either warningCondition or criticalCondition or both | JSON Object | mandatory |
warningCondition/criticalCondition | String | comma separated positive values preceeded with operators. operators supported are >,>=,<,<=,!=,-(between). if we give a single number then it is considered as = operator | 3,>4,<3,!=2,>=2,<=2,!=4,8-20 | mandatory |
noDataCondition | String | No Data Alert will be generate at client and alert definition level. for every 15 minutes it will compute | no data condition should be NO_DATA_ALERT or WARNING_ALERT or CRITICAL_ALERT. | mandatory |
alertTriggerDuration | String | alert generation is happened when thresholds breach continuously upto mention peroid. Minimum duration should be 1 minute. | positive integer values including zero followed by m or s. m means minutes and s means seconds | mandatory |
labels | JSON Array | JSON Array contains the metric labels as JSON Objects | JSON Array contains JSON Objects, each JSON Object contain name and value | optional |
attributes | JSON Array | JSON Array contains the resource attribute labels as JSON Objects | JSON Array contains JSON Objects, each JSON Object contain name as [name or host or ip or uuid] and value | mandatory |
subject | String | alert subject | String | optional |
description | String | alert description | String | optional |
entityType | JSONArray | indicates the entity type of Alert | array should only contains RESOURCE | mandatory |
component | JSONArray | indicates the component of Alert | array contains one label | optional |
status | boolean | alert are generated if status is true | value should be true to generate alerts | optional - default value is true |
Note:
-
Alert Subject and description can be customised with the help of tokens. In the triggered alerts the tokens will get replaced with actual values.
-
Please ensure these tokens have a space before and after them
"subject": "Test host {{$host}} {{$name}} ", "description": "Test host {{$host}} {{$name}} "
Path Parameters
- tenantId
Request Body
application/json
- name
- query
- alertThresholdType
- alertThresholdData
- noDataCondition
- alertTriggerDuration
- labels
- attributes
- subject
- description
- entityType
- component
- status
Request Body Samples
{
"name": "sample_alert_def",
"query": "100*(max by(pod,__name__) (container_memory_working_set_bytes{container=~'ingester.*'})/(1024*1024*1024))/(min by ( pod,__name__)(container_spec_memory_limit_bytes{container=~'ingester.*'} > 0)/(1024*1024*1024))",
"alertThresholdType": "STATIC_THRESHOLD",
"alertThresholdData": {
"warningCondition": ">0",
"criticalCondition": ">0"
},
"noDataCondition": "NO_DATA_ALERT",
"alertTriggerDuration": "0m",
"labels": [
{
"name": "host",
"value": "$host"
},
{
"name": "ip",
"value": "$ip"
}
],
"attributes": [
{
"name": "host",
"value": "$host"
},
{
"name": "ip",
"value": "$ip"
}
],
"subject": "sample_alert_definition_with_new_bucket",
"description": "sample_alert_definition_with_new_bucket",
"entityType": [
"RESOURCE"
],
"component": [
"$ip"
],
"status": true
}
Responses
- Message
- Alert Definition UniqueId
Response Samples
{
"Message": "Successfully created Alert Definition",
"Alert Definition UniqueId ": "85519a93-a19a-4d83-8bd7-24fff25514a8"
}