Creating Alert Rules
You can create alert rules using the following API.
Request URL
POST https://http-collector-observability.sixthsense.rakuten.com/api-externalization/api/v1/rules/
Header
Header key - Authorization
Header value - Bearer {{access_token}} (Navigate to Settings > Access token > Show access token in the SixthSence portal.)
Request
{
"aggregationType": "APDEX",
"aggregationValue": 0,
"channels": [
"string"
],
"filters": [
{
"key": "string",
"value": "string"
}
],
"instances": [
{
"key": "string",
"value": "string"
}
],
"metricDisplayName": "string",
"operation": "EQ",
"period": 0,
"recoveryPeriod": 0,
"ruleName": "string",
"serviceId": "string",
"silencePeriod": 0,
"thresholdDisplayUnit": "string",
"thresholdDisplayValue": "string"
}
Note:
- The timezone for alert rule will be picked from request headers.
- For DYNAMIC baseline alerts, threshold will not have any impact even if it is set by the API.
Parameters | Description |
---|---|
ruleName | Rule name of length 100 |
metricName | Name of the metric returned by /api/v1/metrics/supported |
aggregationType | One among the aggregation list returned by /api/v1/metrics/supported |
aggregationValue | (Optional) Only required when aggregationType is COUNT |
period | Alert Rule evaluation period in minutes |
threshold | Threshold value for the rule, will be 0 by default |
thresholdUnit | (Optional) Threshold unit will be based on metric unit returned by /api/v1/metrics/supported |
For example, if metric unit is TIME supported, units will be ms, s, min etc.
Operations:
- GT : Greater Than
- GTE : Greater Than or Equal to
- LT : Less Than
- LTE : Greater Than or Equal to
- EQ : Equal to
Example:
{
"ruleName": "Error count for code 401 greater than 1 for more than or equal to a count of 1 in a period of 5 mins",
"metricDisplayName": "Error code",
"aggregationType": "SUM",
"aggregationValue": 0,
"period": 5,
"thresholdDisplayValue": "1",
"thresholdDisplayUnit": "na",
"operation": "GT",
"silencePeriod": 5,
"recoveryPeriod": 0,
"serviceId": "eyduYW1lJzonbm9kZS1hcHAtMicsJ3RlYW1JRCc6JzU5ZWRkZDE1LTIwMjQtNDA1OS05OGFlLTc5YTJjZTViYTEzNCcsJ3R5cGUnOidBJ30=.1",
"channels": [
""
],
"filters": [
{
"key": "service_error_code",
"value": "401"
}
],
"instances": [
{
"key": "endpoint",
"value": "http://www.google.com"
},
{
"key": "instance",
"value": "abc"
}
]
}
Response
{
"data": {},
"message": "string",
"success": true
}
Example:
{
"message": "Alert created successfully.",
"success": true,
"data": {
"ruleId": "YTMwNDI2YWItMWU3MC00ODQyLTgwOTItZWY4YzI2YTg3YjMzXzE2NzQwMzkyODg3Njc=",
"ruleName": "Error count for code 401 greater than 1 for more than or equal to a count of 1 in a period of 5 mins",
"metricDisplayName": "Error code",
"aggregationType": "SUM",
"aggregationValue": 0,
"period": 5,
"thresholdDisplayValue": "1",
"thresholdDisplayUnit": "na",
"operation": "GT",
"silencePeriod": 5,
"recoveryPeriod": 0,
"lastUpdatedAt": 1674035660974,
"createdBy": "API user",
"createdAt": 1674035660974,
"modified": 0,
"modifiedBy": "API user",
"active": true,
"serviceId": "eyduYW1lJzonbm9kZS1hcHAtMicsJ3RlYW1JRCc6JzU5ZWRkZDE1LTIwMjQtNDA1OS05OGFlLTc5YTJjZTViYTEzNCcsJ3R5cGUnOidBJ30=.1",
"channels": [
""
],
"filters": [
{
"key": "service_error_code",
"value": "401"
}
],
"instances": [
{
"key": "endpoint",
"value": "http://www.google.com"
},
{
"key": "instance",
"value": "abc"
}
]
}
}