Adaptive triggers

Adaptive triggers are available to customers on select plans

Adaptive triggers are only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.

This topic explains how to use adaptive triggers to automatically serve a different flag variation and send an alert when a metric indicates a problem.

An adaptive trigger serves a different flag variation in response to a metric’s degraded performance over a specified time period. When the metric’s performance crosses a threshold you specify, LaunchDarkly sends an alert to team members or Slack channels you specify, so they can take further action if needed.

Each trigger applies only to the environment where you create it. To monitor the same flag in more than one environment, create a separate trigger in each environment.

Triggers do not run on flags with active experiments

If you create a trigger on a flag that has a running experiment, the trigger will not work. Similarly, if you add a trigger to a flag and then add an experiment to that flag later, the trigger will not work after you start the experiment.

Prerequisites

To use adaptive triggers with flags, you must have a LaunchDarkly role of Owner or Admin, or a custom role that allows the following actions:

  • createTriggers, deleteTriggers, updateFallthrough, and updateTriggers actions for Feature flags.
  • createAlert, deleteAlert, and updateAlertConfiguration actions for Alerts.
Adaptive triggers do not require approval

Adaptive triggers bypass the approval process. Members can add or edit a trigger without an approval, and when a trigger fires, it switches the variation without an approval, even if your environment requires approvals for flag changes.

Adaptive triggers do not work with page viewed metrics or clicked or tapped metrics

Adaptive triggers work only with custom metrics or observability metrics.

Configure adaptive triggers

When you create a trigger, many configuration options are available to ensure the trigger fires only when you mean it to.

Configure source settings

The Source section of the trigger creation screen lets you choose a source for the event to track. Available sources are:

  • LaunchDarkly hosted metrics: Choose from the list of available LaunchDarkly metrics. If the metric you choose measures more than one analysis unit, an Analysis unit menu appears. Use it to choose the context kind the metric is measured per.
  • Logs: The default function is Count. You can choose a Function to aggregate data with and then refine the data into categories with Group by.
  • Traces: The default function is Count. You can choose a Function to aggregate data with and then refine the data into categories with Group by.
  • Sessions: Click + Add filters to refine a query. The adaptive trigger will alert one time for every session that matches the filters.
  • Errors: Click + Add filters to refine a query. The adaptive trigger will alert one time for every open error that matches the filters.
  • Events: Use filters and functions to identify and aggregate data, then refine the data into categories with Group by.
  • Observability Metrics: The default function is Avg. You can choose a Function to aggregate data with and then refine the data into categories with Group by.

If you choose Sessions or Errors and set the threshold Type to Anomaly, the Function and Group by options become available for those sources.

Triggers do not update when a metric changes

LaunchDarkly records the version of the metric a trigger was built from. If you change the metric’s definition later, existing triggers continue to use the definition from when you created them. To pick up the new definition, delete the trigger and create it again.

Configure threshold settings

The Threshold section of the trigger creation screen lets you configure four fields to specify when a trigger should fire. Threshold options are:

  • Type: The threshold type determines which options are available in the other three fields. Choose Constant to fire the alert when the value crosses a fixed number, or Anomaly to fire the alert when the value deviates significantly from its baseline. Anomaly is unavailable for LaunchDarkly hosted metrics that count or total events per unit. Those metrics support constant thresholds only.
  • Condition: The evaluation rule for the alert. Choose Above to fire the alert when the value rises above the alert threshold, or Below to fire the alert when the value falls below it. If you use the Anomaly threshold type, Outside is also available. It fires the alert when the value deviates from its baseline in either direction.
  • Alert threshold: For Constant alerts, enter the value the source must reach before the alert fires. Enter a whole number between 1 and 999,999. If the metric you chose declares a unit, the field displays that unit. For Anomaly alerts, choose a confidence level of 80%, 90%, 95%, or 99%. Higher confidence levels require larger deviations from the baseline before the alert fires.
  • Alert window: Set a window of time in which the conditions must be met for the alert to fire.

Optional advanced threshold settings are also available. They are:

  • Cooldown: Choose a duration from the dropdown to designate how long after an alert has been triggered before it can be triggered again. Setting this to a shorter duration may result in more frequent alerts, but setting it to a longer time period may mean events occur that match your criteria but do not trigger alerts.
  • Evaluation delay: Set a number of minutes to wait after an alert window ends before evaluation begins. This is useful if you know data from your alerts will arrive late.
Triggers monitor an entire environment

An adaptive trigger evaluates its source across the whole environment, not only the contexts that receive the flag. If other flags or code paths in that environment produce the same events, those events also count toward the alert threshold.

Create adaptive triggers

To create an adaptive flag trigger:

  1. In the left navigation, click Flags. The flags list appears.
  2. Find the flag you want to add a trigger to and click its name. The flag’s Targeting tab opens.
  3. In the Rules section, click Add adaptive trigger. The trigger configuration screen appears.
  4. In the Source section, choose a metric source from the dropdown and configure it with the customization options that appear. To learn more, read Configure source settings.
  5. In the Threshold section, set the Type, Condition, Alert threshold, and Alert window. To learn more, read Configure threshold settings. If you chose Sessions as your source and Constant as your type, only the Type field appears, because session alerts fire one time for each matching session.
  6. (Optional) Click to expand Advanced threshold settings.
  7. (Optional) Set a Cooldown period and Evaluation delay duration.
  8. In the Switch variation to section, choose a config variation to serve if the trigger fires.
  9. (Optional) Click + Add notification and designate individual team members, Slack channels, or both to receive notifications if this trigger fires.
  10. Click Add.

An summary of the trigger’s behavior appears at the bottom of the config variation’s rule. When the conditions are met, the trigger fires.

Where alerts appear

When the trigger fires, an alert is sent to the people and channels you specify.

An alert also appears on the observability Alerts page in the LaunchDarkly UI. The alert displays the flag name, the variation name, and other information, such as which Slack channels got a notification. Click into the alert to see more information about it, such as the error rate over a period of time.

Edit adaptive triggers

To edit an adaptive trigger:

  1. Navigate to the Targeting tab of the flag you want to edit a trigger for.
  2. Click the pencil icon next to the trigger.
  3. (Optional) Select a variation to switch to if the trigger is activated. If you have multiple triggers on the rule, they must all switch to the same variation.
  4. (Optional) Click Add notification and choose to Add members or Add Slack channels to be notified when the trigger fires.
  5. Click Save changes.

Delete adaptive triggers

To delete an adaptive trigger, navigate to the Targeting tab of the flag you want to delete a trigger for and click the x next to the trigger. LaunchDarkly removes the trigger from the rule.

Delete trigger alerts

You cannot disable or delete alerts that come from triggers. Instead, delete the trigger to remove the alert, or edit the trigger to change the alert threshold.