アラートルールの作成
以下の API を使用してアラートルールを作成できます。
リクエストURL
POST https://http-collector-observability.sixthsense.rakuten.com/api-externalization/api/v1/rules/
ヘッダー
ヘッダーキー :Authorization
ヘッダー値:Bearer {{access_token}} (SixthSenseポータルで [設定] > [アクセストークン] > [アクセストークンの表示] に移動)
リクエスト
{
"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"
}
注記:
- アラートルールのタイムゾーンは、リクエストヘッダーから取得されます。
- 動的ベースラインアラートの場合、API でしきい値が設定されていても影響はありません。
パラメータ | 内容 |
---|---|
ruleName | ルール名。最大100文字 |
metricName | /api/v1/metrics/supportedで返されるメトリクス名 |
aggregationType | /api/v1/metrics/supportedで返される集約タイプのいずれか |
aggregationValue | (オプション) aggregationType が COUNT の場合のみ必要 |
period | アラートルールの評価期間(分単位) |
threshold | ルールのしきい値。デフォルトは 0 |
thresholdUnit | (オプション) しきい値の単位は、/api/v1/metrics/supported で返されるメトリクスの単位に基づきます。| |
例えば、メトリクスの単位が TIME をサポートしている場合、単位は ms、s、min などになります。
オペレーション:
- GT : Greater Than(より大きい)
- GTE : Greater Than or Equal to(以上)
- LT : Less Than(より小さい)
- LTE : Less Than or Equal to(以下)
- EQ : Equal to(等しい)
例:
{
"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"
}
]
}
レスポンス
{
"data": {},
"message": "string",
"success": true
}
例:
{
"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"
}
]
}
}