Rules

Learn more about the Rules section of the Bearer Dashboard

Rules provide a way to manage notifications based on API performance.

Rules Overview

Selecting the "Add Rule" button will launch the Add Rule section, where you can create a new rule for any or all APIs.

Add rule form

When creating a new rule, you can select notification thresholds, delivery types, and which environment to watch.

Incident Thresholds

When adding a new rule, you can select the API it will affect, the trigger threshold, the method to be notified, and the environments to monitor. Rules currently support the following trigger criteria:

  • Average Latency (in milliseconds)

  • Consumption (Number)

  • Error Rate (%)

Rules monitor over the set time window. Adjusting the time window to a larger number can allow rules to be more forgiving of short-term problems, while setting a smaller time window will result in more aggressive reporting.

Notification Type

Rules in Bearer currently support email, Slack, and webhook notifications.

  • Email: Receive an email at the address associated with your Bearer account.

  • Slack: Select a workspace and channel to send Slack notifications

  • Webhook: Enter the URL to consume a webhook

Webhook specification

Webhooks are sent as a POST request containing a JSON payload. Below is the shape of an example webhook:

{
api: {
id: '[INTERNAL API ID]',
name: '[Name of API which triggered incident e.g. GitHub]'
},
incident: {
id: '[INTERNAL INCIDENT ID]',
started_at: 1579540568, // Starting Timestamp
completed_at: 1579540868, // Ending Timestamp
complete: true,
link: 'https://app.bearer.sh/incidents'
},
rule: {
id: '[INTERNAL RULE ID]',
name: '[Name of incident rule e.g. My Rule]',
description: 'Consumption for API calls reaches 1 call over 5 mins',
metric: 'request_count',
call_type: 'api',
comparison: 'value_up',
threshold: 1,
threshold_units: 'calls',
period_in_mins: 5,
link: 'https://app.bearer.sh/rules'
},
app: {
id: '[INTERNAL APP ID]',
name: 'My App' // Name of the affected application
},
environment: {
name: '[Environment in which incident occurred]'
}
}

When a rule is triggered, it creates a new incident in the Incidents section of the dashboard.