Creating Static Alerts

Static alerts can be used to compare a specific field to a static value. For instance, you may want to set up an alert to fire if more than 10 HTTP ‘401 Not Authorized’ errors occur within 15 minutes. These types of alerts work well when the threshold is constant and predictable.

Setting up a static alert in Moesif is very simple. Using the above example, let’s create an example alert. First, you’ll want to click the Alert Rules button from the left navigation pane.

Moesif Alerts dashboard screen

NOTE: If you haven’t set up any alerts before, you’ll notice a few that are there by default. These are just a few alerts that we have found useful for our users. You are able to delete or modify these to suit your needs.

Once on the Alert Rules screen, you want to click “+ Alert Rule” in the top right corner of the screen.

Moesif create alert button

Creating a New Alert

From here, you’ll see a new screen where you can input your alert criteria. On the right of the screen, you’ll see a summary of the alert you are about to create (or are updating if the alert rule already exists).

Moesif create alert input screen

Firstly, in the Name text box, we will name our alert.

Moesif Alert name field

Next, you’ll want to make sure that the alert is active by having checked the On checkbox. You’ll also want the alert type to be set to Static Alert.

Moesif Alert type field with Static selected

After this, we will set the Threshold field. Here we want to specify how many occurrences of the event should occur before an alert is sent.

Moesif set alert threshold number

Creating an Alert Channel

We also want to specify which channels this alert should be sent to. Currently, Moesif supports sending alerts to the following channels:

  • Email
  • SMS
  • Slack
  • PagerDuty
  • Webhooks

To add a channel to send the alert to, click the New Channel button.

NOTE: If you have already added the channel you want previously, simply click on the “Select a channel” dropdown and select your previously added channel.

After clicking this, you’ll see a new modal appear which allows you to pick a channel and add in the relevant details. In this example, I will add a new Email channel.

Moesif add new alert channel

The fields for a new email channel include:

Channel Name - This is the name that you want the channel to display as

Channel Type - This is the type of channel you want the alert to go to. Depending on the channel selected, different inputs will appear for configuration.

Email Address - This is the email address the alert will be delivered to

Notification Throttle - This controls the max number of alerts that can be sent during a given time period. This helps to make sure that the right amount of alerts are being sent without spamming the recipient.

Once you’ve filled out the fields, click Save.

Now you will be able to select your newly added channel from the Send to dropdown. Once you’ve found your entry, click to add it as a delivery channel for your alert.

Moesif selecte alert channel to send notifications

You should now see your channel added to the alert.

Moesif confirm alert channel

We will now set the interval for metric aggregation for the alert. The interval that we set will dictate the time interval that the alert criteria will evaluate against. Hourly or smaller intervals are evaluated continuously every minute in overlapping rolling windows. For example, if you select 15 minutes, Moesif will aggregate the metric from the last 15 minutes with a series like so: 12:00 to 12:15, 12:01 to 12:16, 12:02 to 12:17, and so on. On the other hand, daily or larger intervals are evaluated once per calendar interval. This means if you select daily, Moesif will aggregate your metric from 12:00 AM to 11:59 PM and send a daily report.

For this specific alert, we will select “15 minutes” from the dropdown.

Moesif alert screens set time interval

Creating an Alert Filter

Lastly, and most importantly, we will set the alert filter. This is where we specify which events we actually want to aggregate. For this filter, we will simply look for any 401 response code that occurs in an API response.

To build this filter, click on Select field in the Filters pane. In the first criteria you will select Response, and in the sub-type, select Status Code.

Moesif set alert filter

Moesif alert filter field dropdown

After this, you will click Select operator to choose the operator for the filter. For this comparison, we will use “=” operator.

Moesif set alert value

After the operator is selected, an input for value will appear. For the value here we will type in “401” and then select “401 Unauthorized” from the dropdown.

Moesif set alert value with dropdown

Once selected, your filter is then complete and ready to be used. It should look like this:

Moesif confirm alert filter criteria

Saving an Alert

Now with everything configured, we will click Create to create the alert in Moesif.

Moesif create alert

You’ll then have a confirmation dialog appear showing you the alert criteria and important configuration items. Do a final review and click Create once again.

Moesif create alert final review

After this, we will navigate back to the Alerts Rules screen. Here we will see our alert has been added and is active.

Created alert on Moesif alerts dashboard

Receiving an Alert

Once the alert is fired, you will receive an email (or alert in another channel if you set it up) that will show your alert threshold has been hit.

Moesif alert email

And that’s it! You’ve now configured your first static alert in Moesif. With that, you can rest easy knowing that you’ll be notified of any events that you are filtering for. This functionality will help developers, support, and management teams to provide better service to users and to more actively monitor and resolve issues within your APIs.

From Moesif

Updated: