|
| 1 | +# Get Alarm Runtime Status |
| 2 | + |
| 3 | +OAP calculates the alarm conditions in the memory based on the alarm rules and the metrics data. |
| 4 | +The following APIs are exposed to make the alerting running kernel visible. |
| 5 | + |
| 6 | +## Get Alarm Running Rules |
| 7 | + |
| 8 | +Return the list of alarm running rules. |
| 9 | + |
| 10 | +- URL, `http://{core restHost}:{core restPort}/status/alarm/rules` |
| 11 | +- HTTP GET method. |
| 12 | + |
| 13 | +```json |
| 14 | +{ |
| 15 | + "ruleNames": [ |
| 16 | + "service_percentile_rule", |
| 17 | + "service_resp_time_rule" |
| 18 | + ] |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +## Get Alarm Running Rule Info |
| 23 | + |
| 24 | +Return the detailed information of the alarm running rule. |
| 25 | + |
| 26 | +- URL, `http://{core restHost}:{core restPort}/status/alarm/rules/{ruleName}` |
| 27 | +- HTTP GET method. |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "ruleName": "service_resp_time_rule", |
| 32 | + "expression": "sum(service_resp_time > baseline(service_resp_time,upper)) >= 1", |
| 33 | + "period": 10, |
| 34 | + "silentPeriod": 10, |
| 35 | + "additonalPeriod": 0, |
| 36 | + "includeNames": [ |
| 37 | + "mock_a_service", |
| 38 | + "mock_b_service", |
| 39 | + "mock_c_service" |
| 40 | + ], |
| 41 | + "excludeNames": [], |
| 42 | + "includeNamesRegex": "", |
| 43 | + "excludeNamesRegex": "", |
| 44 | + "affectedEntities": [ |
| 45 | + { |
| 46 | + "scope": "SERVICE", |
| 47 | + "name": "mock_b_service" |
| 48 | + }, |
| 49 | + { |
| 50 | + "scope": "SERVICE", |
| 51 | + "name": "mock_a_service" |
| 52 | + }, |
| 53 | + { |
| 54 | + "scope": "SERVICE", |
| 55 | + "name": "mock_c_service" |
| 56 | + } |
| 57 | + ], |
| 58 | + "tags": [ |
| 59 | + { |
| 60 | + "key": "level", |
| 61 | + "value": "WARNING" |
| 62 | + } |
| 63 | + ], |
| 64 | + "hooks": [ |
| 65 | + "webhook.default", |
| 66 | + "wechat.default" |
| 67 | + ], |
| 68 | + "includeMetrics": [ |
| 69 | + "service_resp_time" |
| 70 | + ], |
| 71 | + "formattedMessages": [ |
| 72 | + { |
| 73 | + "mock_b_service": "Response time of service mock_b_service is more than upper baseline in 1 minutes of last 10 minutes." |
| 74 | + }, |
| 75 | + { |
| 76 | + "mock_a_service": "Response time of service mock_a_service is more than upper baseline in 1 minutes of last 10 minutes." |
| 77 | + }, |
| 78 | + { |
| 79 | + "mock_c_service": "Response time of service mock_c_service is more than upper baseline in 1 minutes of last 10 minutes." |
| 80 | + } |
| 81 | + ] |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +- `additonalPeriod` is the additional period if the expression includes the [increase/rate function](../api/metrics-query-expression.md#trend-operation). |
| 86 | +This additional period is used to enlarge window size for calculating the trend value. |
| 87 | +- `affectedEntities` is the entities that have metrics data and being calculated by the alarm rule. |
| 88 | +- `formattedMessages` is the result message according to the message template and the affected entities. |
| 89 | + |
| 90 | +## Get Alarm Running Context |
| 91 | + |
| 92 | +Return the running context of the alarm rule. |
| 93 | + |
| 94 | +- URL, `http://{core restHost}:{core restPort}/status/alarm/{ruleName}/{entityName}` |
| 95 | +- HTTP GET method. |
| 96 | + |
| 97 | +```json |
| 98 | +{ |
| 99 | + "expression": "sum(service_resp_time > baseline(service_resp_time,upper)) >= 1", |
| 100 | + "endTime": "2025-02-12T13:39:00.000", |
| 101 | + "additionalPeriod": 0, |
| 102 | + "size": 10, |
| 103 | + "silenceCountdown": 10, |
| 104 | + "windowValues": [ |
| 105 | + { |
| 106 | + "index": 0, |
| 107 | + "metrics": [] |
| 108 | + }, |
| 109 | + { |
| 110 | + "index": 1, |
| 111 | + "metrics": [] |
| 112 | + }, |
| 113 | + { |
| 114 | + "index": 2, |
| 115 | + "metrics": [] |
| 116 | + }, |
| 117 | + { |
| 118 | + "index": 3, |
| 119 | + "metrics": [] |
| 120 | + }, |
| 121 | + { |
| 122 | + "index": 4, |
| 123 | + "metrics": [] |
| 124 | + }, |
| 125 | + { |
| 126 | + "index": 5, |
| 127 | + "metrics": [] |
| 128 | + }, |
| 129 | + { |
| 130 | + "index": 6, |
| 131 | + "metrics": [] |
| 132 | + }, |
| 133 | + { |
| 134 | + "index": 7, |
| 135 | + "metrics": [ |
| 136 | + { |
| 137 | + "timeBucket": 202502121437, |
| 138 | + "name": "service_resp_time", |
| 139 | + "value": "6000" |
| 140 | + } |
| 141 | + ] |
| 142 | + }, |
| 143 | + { |
| 144 | + "index": 8, |
| 145 | + "metrics": [] |
| 146 | + }, |
| 147 | + { |
| 148 | + "index": 9, |
| 149 | + "metrics": [] |
| 150 | + } |
| 151 | + ], |
| 152 | + "mqeMetricsSnapshot": { |
| 153 | + "service_resp_time": "[{\"metric\":{\"labels\":[]},\"values\":[{\"id\":\"202502121430\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121431\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121432\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121433\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121434\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121435\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121436\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121437\",\"doubleValue\":6000.0,\"isEmptyValue\":false},{\"id\":\"202502121438\",\"doubleValue\":0.0,\"isEmptyValue\":true},{\"id\":\"202502121439\",\"doubleValue\":0.0,\"isEmptyValue\":true}]}]", |
| 154 | + "baseline(service_resp_time,upper)": "[{\"metric\":{\"labels\":[]},\"values\":[{\"id\":\"202502121430\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121431\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121432\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121433\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121434\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121435\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121436\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121437\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121438\",\"doubleValue\":10.0,\"isEmptyValue\":false},{\"id\":\"202502121439\",\"doubleValue\":10.0,\"isEmptyValue\":false}]}]" |
| 155 | + } |
| 156 | +} |
| 157 | +``` |
| 158 | +`size` is the window size. Equal to the `period + additionalPeriod`. |
| 159 | +`silenceCountdown` is the countdown of the silence period. -1 means silence countdown is not running. |
| 160 | +`windowValues` is the original metrics data. The `index` is the index of the window, starting from 0. |
| 161 | +`mqeMetricsSnapshot` is the metrics data in the MQE format. When checking conditions, these data will be calculated according to the expression. |
0 commit comments