**Alerts** =============== **Fetch Alerts Count** ++++++++++++++++++++++ .. http:get:: /_alerting/alerts/_count **Description** Returns the count of alerts generated for a Function during the specified time range. The count is split into high, medium, and low Severity levels. **HTTP Method** GET **Endpoint** ``/_alerting/alerts/_count`` **Request Header** ``Authorization`` `Basic Token` **Request Parameters** Query Parameters - ``function_id`` (string, *required*): The ID of the Function. - ``from`` (string, *optional*): The start of the time range. Default is t-7d. - ``to`` (string, *optional*): The end of the time range. Default is now. **Sample Request** .. code-block:: sh curl -X GET 'https://app.4pointx.com/_alerting/alerts/_count?function_id=f14600e7-cf2c-4f7f-af99-784b07b73a99&from=2022-12-02T12:01:00.000Z&to=2022-12-09T12:01:59.999Z' \ -H 'Authorization: Basic <token>' **Sample Response** Success .. sourcecode:: json { "high": 4, "low": 0, "medium": 2, } Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "Function does not exist" } } .. sourcecode:: json { "error": { "status": 500, "message": "Error occurred" } } **Fetch List of Alerts** ++++++++++++++++++++++++++++ .. http:get:: /_alerting/alerts/_list **Description** Returns a list of alerts along with their details for a specified Function and time range. **HTTP Method** GET **Endpoint** ``/_alerting/alerts/_list`` **Request Header** ``Authorization`` `Basic Token` **Request Parameters** Query Parameters - ``function_id`` (string, *required*): The ID of the Function. - ``asset_id`` (string, *optional*): The ID of the Asset. - ``is_hidden`` (intiger, *required*): fetch alerts for only hidden watchers - ``from`` (string, *optional*): The start of the time range. Default is t-7d. - ``to`` (string, *optional*): The end of the time range. Default is now. **Sample Request** .. code-block:: sh curl -X GET 'https://app.4pointx.com/_alerting/alerts/_list?function_id=45c98f40-75e3-49e7-b178-d25ec878db79&is_hidden=0&from=2024-10-12T08:02:50.046Z&to=2024-12-12T10:50:06.413Z' \ -H 'Authorization: Basic <token>' .. code-block:: sh curl -X GET 'https://app.4pointx.com/_alerting/alerts/_list?function_id=45c98f40-75e3-49e7-b178-d25ec878db79&from=2024-10-12T08:02:50.046Z&to=2024-12-12T10:50:06.413Z&is_hidden=1&asset_id=d3fe9877-b4f4-477e-a790-96a22a4cc665' \ -H 'Authorization: Basic <token>' **Sample Response** Success .. sourcecode:: json [ { "_id": "bcaca22b-7f4e-4e9e-8d35-c21b30043442", "asset": "Demo Asset", "duration": 2210575, "end_time": null, "monitor": "Tecom Condition 2.0 (POC)", "monitor_id": "338f0ce8-56c1-45ad-8b44-1237548137a7", "note": "", "severity": "High", "start_time": "2024-11-19T02:51:08+0530", "state": "active", "tag": { "velocity_x_338f0ce8-56c1-45ad-8b44-1237548137a7": "velocity_x" }, "trigger_id": "9a75b6e4-12c6-450b-b815-aa9a33f00df8", "trigger_name": "warning", "type_of_data": "Condition", "watcher_id": "afe4e7e6-7a98-4a17-a5e1-016ea12c4f4f", "watcher_name": "CBM: GW40 (CM POC) " }, { "_id": "9ae561ae-c58b-4c5c-a6a4-10bdbad485d5", "asset": "Demo Asset", "duration": 2210575, "end_time": null, "monitor": "Tecom Condition 2.0 (POC)", "monitor_id": "338f0ce8-56c1-45ad-8b44-1237548137a7", "note": "", "severity": "High", "start_time": "2024-11-19T02:51:08+0530", "state": "active", "tag": { "acceleration_x_338f0ce8-56c1-45ad-8b44-1237548137a7": "acceleration_x" }, "trigger_id": "14c56040-e882-4961-bd52-ffcd52611aa3", "trigger_name": "warning", "type_of_data": "Condition", "watcher_id": "afe4e7e6-7a98-4a17-a5e1-016ea12c4f4f", "watcher_name": "CBM: GW40 (CM POC) " } ] Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "Function does not exist" } } **Fetch Alerts Trend** ++++++++++++++++++++++++++++++ .. http:get:: /_alerting/alerts/_trend **Description** Returns the count of alerts over time split by Severity levels. **HTTP Method** GET **Endpoint** ``/_alerting/alerts/_trend`` **Request Header** ``Authorization`` `Basic Token` **Request Parameters** Query Parameters - ``function_id`` (string, *required/optional*): The ID of the Function. - ``trigger_id`` (string, *optional/required*): The ID of the Trigger - ``from`` (string, *optional*): The start of the time range. Default is t-7d. - ``to`` (string, *optional*): The end of the time range. Default is now. **Sample Request** .. code-block:: sh curl -X GET 'https://app.4pointx.com/_alerting/alerts/_trend?function_id=f14600e7-cf2c-4f7f-af99-784b07b73a99&from=2022-12-02T12:01:00.000Z&to=2022-12-09T12:01:59.999Z' \ -H 'Authorization: Basic <token>' .. code-block:: sh curl -X GET 'https://app.4pointx.com/_alerting/alerts/_trend?trigger_id=a256baed-d856-4fcf-a6e5-82be0520fde5&from=2022-12-02T12:01:00.000Z&to=2022-12-09T12:01:59.999Z' \ -H 'Authorization: Basic <token>' **Sample Response** Success .. code-block:: json { "high": [ { "time": 166726070280400, "total": 1 }, { "time": 166726022247400, "total": 1 } ], "low": [], "medium": [ { "time": 166726020792400, "total": 1 }, { "time": 166726021065400, "total": 1 } ] } Error .. sourcecode:: json { "error": { "status": 401, "message": "Unauthorized access to module by general-user" } } .. sourcecode:: json { "error": { "status": 400, "message": "Insufficient inputs" } } .. sourcecode:: json { "error": { "status": 400, "message": "Function does not exist" } } .. sourcecode:: json { "error": { "status": 500, "message": "Error occurred" } } **Add a Note** ++++++++++++++++++++++++ .. http:delete:: /_alerting/alerts/<alert_id> **Description** Add a note to the alert details. **HTTP Method** PUT **Endpoint** ``/_alerting/alert/<alert_id>`` **Request Header** ``Authorization`` `Basic Token` **Request Parameters** URL Parameters - ``alert_id`` (string, *required*) The ID of the alert. **Sample Request** .. code-block:: sh curl -X PUT 'https://app.4pointx.com/_alerting//alerts/66364e9a-99ab-4e56-a0ca-81b28bc0dbe7' \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic <token>' \ -d '{ "note": "Note added" }' **Sample Response** Success .. sourcecode:: json "Note added" Error .. sourcecode:: json { "error": { "status": 500, "message": "Something went wrong" } }