Skip to main content
Version: 1.2

Querying alerts

Overview​

ToBeAlert provides several endpoints to retrieve alerts, whether by ID, by view, by service, or as a full paginated list. All endpoints require a valid API key.

Authorization: Key YOUR_API_KEY_HERE

Get a single alert​

GET /api/alert/<alert_id>
Authorization: Key YOUR_API_KEY

Returns the full details of a single alert by its ID.

Example​

Get a single alert by its ID

curl -X GET "http://your-tobealert.com:9000/api/alert/ALERT_ID" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY"

Response​

{
"status": "ok",
"total": 1,
"alert": {
"id": "abc123",
"resource": "web-01.example.com",
"event": "ServerDown",
"environment": "production",
"severity": "critical",
"status": "open",
"text": "Server is not responding",
"service": ["web-service"],
"group": "infrastructure",
"tags": ["linux", "production"],
"attributes": {},
"origin": "nagios",
"createTime": "2025-04-15T10:00:00Z",
"lastReceiveTime": "2025-04-15T10:30:00Z",
"duplicateCount": 3,
"trendIndication": "moreSevere"
}
}

Errors​

CodeReason
404Alert not found

List all alerts​

GET /api/alerts
Authorization: Key YOUR_API_KEY

Returns a paginated list of all alerts across all views. Requires the requesting user to belong to the all_events group.

Query parameters​

Filtering​

ParameterTypeDescriptionExample
idStringFilter by alert ID?id=abc123
resourceStringFilter by resource name?resource=web-01
resourceParentStringFilter by parent resource?resourceParent=web-cluster
eventStringFilter by event type?event=ServerDown
environmentStringFilter by environment?environment=production
severityStringFilter by severity level?severity=critical
statusStringFilter by alert status?status=open
serviceStringFilter by service (array match)?service=web-service
sourceIdStringFilter by source application?sourceId=nagios
groupStringFilter by group?group=infrastructure
originStringFilter by origin?origin=nagios
typeStringFilter by alert type?type=exceptionAlert
tagsStringFilter by tag?tags=linux
textStringFilter by description text?text=not+responding
valueStringFilter by metric value?value=503
trendIndicationStringFilter by trend?trendIndication=moreSevere
repeatBooleanFilter repeating alerts?repeat=true
duplicateCountIntegerFilter by duplicate count?duplicateCount=5
from-dateISO 8601Alerts updated after this date?from-date=2025-04-01T00:00:00Z
to-dateISO 8601Alerts updated before this date?to-date=2025-04-15T23:59:59Z
attributes.<key>StringFilter by attribute value?attributes.region=us-west-2

Sorting​

Use the sort-by parameter. Prefix with - to sort descending.

ExampleDescription
?sort-by=severitySort by severity ascending
?sort-by=-lastReceiveTimeSort by last received, newest first
?sort-by=-createTimeSort by creation time, newest first

Supported sort fields: id, resource, event, environment, severity, status, group, origin, createTime, lastReceiveTime, updateTime, duplicateCount, trendIndication, value, tags.

Pagination​

ParameterDefaultDescription
page1Page number
page-sizeConfig defaultNumber of alerts per page

Example​

List all critical production alerts, sorted by most recently received

curl -X GET "http://your-tobealert.com:9000/api/alerts?environment=production&severity=critical&sort-by=-lastReceiveTime" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY"

Response​

{
"status": "ok",
"page": 1,
"pageSize": 50,
"pages": 4,
"more": true,
"alerts": [ /* array of alert objects */ ],
"total": {
"severity": { "critical": 5, "warning": 12, "normal": 30 },
"status": { "open": 17, "ack": 8, "closed": 22 },
"environment": { "production": 25, "staging": 10, "dev": 12 },
"source_id": { "nagios": 20, "cloudwatch": 17 },
"trend_indication": { "moreSevere": 5, "lessSevere": 3, "noChange": 39 },
"total": 47,
"total_filtered": 47
},
"lastTime": "2025-04-15T10:30:00Z"
}
note

The total object contains global counts (unfiltered by your query) for all breakdown dimensions, plus total_filtered which reflects the current filter. This is useful for rendering sidebar badges without extra requests.

Errors​

CodeReason
403User is not a member of the all_events group

List alerts by view​

GET /api/alerts/by_view/<view_id>
Authorization: Key YOUR_API_KEY

Returns a paginated list of alerts belonging to a specific view (group). The user must be a member of the view or have admin scope.

Path parameters​

ParameterDescription
view_idThe ID of the view (group) to query

Query parameters​

Supports the same filtering, sorting, and pagination parameters as List All Alerts. Filters are combined with the view's own query using AND.

Example​

List critical alerts for a specific view

curl -X GET "http://your-tobealert.com:9000/api/alerts/by_view/VIEW_ID?severity=critical&sort-by=-lastReceiveTime&page-size=25" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY"

Response​

Same structure as List All Alerts. The total object reflects counts scoped to the view (before your additional filters), and total_filtered is the result after your filters are applied.

{
"status": "ok",
"page": 1,
"pageSize": 50,
"pages": 2,
"more": false,
"alerts": [ /* array of alert objects */ ],
"total": {
"severity": { "critical": 3, "warning": 5 },
"status": { "open": 6, "ack": 2 },
"environment": { "production": 8 },
"source_id": { "nagios": 8 },
"trend_indication": { "moreSevere": 1, "noChange": 7 },
"total": 8,
"total_filtered": 8
},
"lastTime": "2025-04-15T10:30:00Z"
}

Errors​

CodeReason
403User does not have access to this view
404View not found

List alerts by service​

GET /api/alerts/by_service/<service_name>
Authorization: Key YOUR_API_KEY

Returns all alerts that include service_name in their service array. This is a simple, unfiltered endpoint with no pagination.

Path parameters​

ParameterDescription
service_nameThe service name to search for

Example​

List all alerts for the payment-service service

curl -X GET "http://your-tobealert.com:9000/api/alerts/by_service/payment-service" \
-H "Content-Type: application/json" \
-H "Authorization: Key YOUR_API_KEY"

Response​

{
"status": "ok",
"total": 3,
"alerts": [ /* array of alert objects */ ]
}

Advanced filtering examples​

Filter by multiple severities​

GET /api/alerts/by_view/prod-view?severity=critical&severity=major

Filter by date range​

GET /api/alerts/by_view/prod-view?from-date=2025-04-01T00:00:00Z&to-date=2025-04-15T23:59:59Z

Filter by attribute value​

GET /api/alerts/by_view/prod-view?attributes.region=us-west-2

Sort by most recent and paginate​

GET /api/alerts/by_view/prod-view?sort-by=-lastReceiveTime&page=2&page-size=25

Filter by tag​

GET /api/alerts/by_view/prod-view?tags=aws&tags=production