|
1 | 1 | Alert History Import and Export API |
2 | 2 | =================================== |
3 | 3 |
|
4 | | -GET https://api.robusta.dev/api/alerts |
| 4 | +GET https://api.robusta.dev/api/query/alerts |
5 | 5 | -------------------------------------- |
6 | 6 |
|
7 | 7 | Use this endpoint to export alert history data. You can filter the results based on specific criteria using query parameters such as ``alert_name``, ``account_id``, and time range. |
@@ -149,6 +149,127 @@ Response Fields |
149 | 149 | - The node where the resource is located. |
150 | 150 |
|
151 | 151 |
|
| 152 | +GET `https://api.robusta.dev/api/query/report` |
| 153 | +-------------------------------------- |
| 154 | + |
| 155 | +Use this endpoint to retrieve aggregated alert data, including the count of each type of alert during a specified time range. Filters can be applied using query parameters such as `account_id` and the time range. |
| 156 | + |
| 157 | + |
| 158 | +Query Parameters |
| 159 | +^^^^^^^^^^^^^^^ |
| 160 | + |
| 161 | +.. list-table:: |
| 162 | + :widths: 20 10 70 10 |
| 163 | + :header-rows: 1 |
| 164 | + |
| 165 | + * - Parameter |
| 166 | + - Type |
| 167 | + - Description |
| 168 | + - Required |
| 169 | + * - ``account_id`` |
| 170 | + - string |
| 171 | + - The unique account identifier (found in your ``generated_values.yaml`` file). |
| 172 | + - Yes |
| 173 | + * - ``start_ts`` |
| 174 | + - string |
| 175 | + - Start timestamp for the query (in ISO 8601 format, e.g., ``2024-10-27T04:02:05.032Z``). |
| 176 | + - Yes |
| 177 | + * - ``end_ts`` |
| 178 | + - string |
| 179 | + - End timestamp for the query (in ISO 8601 format, e.g., ``2024-11-27T05:02:05.032Z``). |
| 180 | + - Yes |
| 181 | + |
| 182 | + |
| 183 | +Example Request |
| 184 | +^^^^^^^^^^^^^^^ |
| 185 | + |
| 186 | +The following `curl` command demonstrates how to query aggregated alert data for a specified time range: |
| 187 | + |
| 188 | +.. code-block:: bash |
| 189 | +
|
| 190 | + curl --location 'https://api.robusta.dev/api/query/report?account_id=XXXXXX-XXXX_XXXX_XXXXX7&start_ts=2024-10-27T04:02:05.032Z&end_ts=2024-11-27T05:02:05.032Z' \ |
| 191 | + --header 'Authorization: Bearer TOKEN_HERE' |
| 192 | +
|
| 193 | +
|
| 194 | +In the command, make sure to replace the following placeholders: |
| 195 | + |
| 196 | +- **`account_id`**: Your account ID, which can be found in your `generated_values.yaml` file. |
| 197 | +- **`TOKEN_HERE`**: Your API token for authentication. Generate this token in the platform by navigating to **Settings** -> **API Keys** -> **New API Key**, and creating a key with the "Read Alerts" permission. |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | +Request Headers |
| 202 | +^^^^^^^^^^^^^^^ |
| 203 | + |
| 204 | +.. list-table:: |
| 205 | + :widths: 30 70 |
| 206 | + :header-rows: 1 |
| 207 | + |
| 208 | + * - Header |
| 209 | + - Description |
| 210 | + * - ``Authorization`` |
| 211 | + - Bearer token for authentication (e.g., ``Bearer TOKEN_HERE``). The token must have "Read Alerts" permission. |
| 212 | + |
| 213 | +Response Format |
| 214 | +^^^^^^^^^^^^^^^ |
| 215 | + |
| 216 | +The API will return a JSON array of aggregated alerts, with each object containing: |
| 217 | + |
| 218 | +- **`aggregation_key`**: The unique identifier of the alert type (e.g., `KubeJobFailed`). |
| 219 | +- **`alert_count`**: The total count of occurrences of this alert type within the specified time range. |
| 220 | + |
| 221 | +Example Response |
| 222 | +^^^^^^^^^^^^^^^ |
| 223 | +.. code-block:: json |
| 224 | + [ |
| 225 | + {"aggregation_key": "KubeJobFailed", "alert_count": 17413}, |
| 226 | + {"aggregation_key": "KubePodNotReady", "alert_count": 11893}, |
| 227 | + {"aggregation_key": "KubeDeploymentReplicasMismatch", "alert_count": 2410}, |
| 228 | + {"aggregation_key": "KubeDeploymentRolloutStuck", "alert_count": 923}, |
| 229 | + {"aggregation_key": "KubePodCrashLooping", "alert_count": 921}, |
| 230 | + {"aggregation_key": "KubeContainerWaiting", "alert_count": 752}, |
| 231 | + {"aggregation_key": "PrometheusRuleFailures", "alert_count": 188}, |
| 232 | + {"aggregation_key": "KubeMemoryOvercommit", "alert_count": 187}, |
| 233 | + {"aggregation_key": "PrometheusOperatorRejectedResources", "alert_count": 102}, |
| 234 | + {"aggregation_key": "KubeletTooManyPods", "alert_count": 94}, |
| 235 | + {"aggregation_key": "NodeMemoryHighUtilization", "alert_count": 23}, |
| 236 | + {"aggregation_key": "TargetDown", "alert_count": 19}, |
| 237 | + {"aggregation_key": "test123", "alert_count": 7}, |
| 238 | + {"aggregation_key": "KubeAggregatedAPIDown", "alert_count": 4}, |
| 239 | + {"aggregation_key": "KubeAggregatedAPIErrors", "alert_count": 4}, |
| 240 | + {"aggregation_key": "KubeMemoryOvercommitTEST2", "alert_count": 1}, |
| 241 | + {"aggregation_key": "TestAlert", "alert_count": 1}, |
| 242 | + {"aggregation_key": "TestAlert2", "alert_count": 1}, |
| 243 | + {"aggregation_key": "dsafd", "alert_count": 1}, |
| 244 | + {"aggregation_key": "KubeMemoryOvercommitTEST", "alert_count": 1}, |
| 245 | + {"aggregation_key": "vfd", "alert_count": 1} |
| 246 | + ] |
| 247 | +
|
| 248 | +
|
| 249 | +
|
| 250 | +Response Fields |
| 251 | +^^^^^^^^^^^^^^^ |
| 252 | +.. list-table:: |
| 253 | + :widths: 25 10 70 |
| 254 | + :header-rows: 1 |
| 255 | + |
| 256 | + * - Field |
| 257 | + - Type |
| 258 | + - Description |
| 259 | + * - ``aggregation_key`` |
| 260 | + - string |
| 261 | + - The unique key representing the type of alert (e.g., ``KubeJobFailed``). |
| 262 | + * - ``alert_count`` |
| 263 | + - integer |
| 264 | + - The number of times this alert occurred within the specified time range. |
| 265 | + |
| 266 | +Notes |
| 267 | +^^^^^^^^^^^^^^^ |
| 268 | + |
| 269 | +- Ensure that the `start_ts` and `end_ts` parameters are in ISO 8601 format and are correctly set to cover the desired time range. |
| 270 | +- Use the correct `Authorization` token with sufficient permissions to access the alert data. |
| 271 | + |
| 272 | + |
152 | 273 | POST https://api.robusta.dev/api/alerts |
153 | 274 | -------------------------------------- |
154 | 275 | Use this endpoint to send alert data to Robusta. You can send up to 1000 alerts in a single request. |
|
0 commit comments