IBM Cloud Docs
Targeting feature flags to segments

Targeting feature flags to segments

As an app owner, create, and manage feature flags, add them to collections and use them in your app by using SDKs. You can also control the applicability of a feature by enabling or disabling it at run time.

You can add an approval process flow for any configuration changes initiated through an App Configuration environment by using the ServiceNow integration. The approval process flow is applicable to an App Configuration environment like dev, stage, and production. For more information, see Manage workflow.

A feature can be enabled or disabled to all the collection users or to a specific set of users and devices or to a certain percentage of specific set of users and devices.

Enabling or disabling features can be coordinated by defining a start and end time and date. Also, choose a specific day on which a defined feature can be enabled or disabled. See Scheduled Flags for more information on how to set start and end time, date and choosing a specific day for toggling of your feature flag.

By default, the Feature flags page displays the list of feature flags that are created in the current environment of the App Configuration service instance along with details of the record like Name, Type, Last Updated, Last Evaluated, Segments that are targeted. Flag types are categorized as Boolean, Numeric, or String.

  • A Boolean flag has two values and you can set the default value as 'true' or 'false'.
  • A String type flag supports data in the form of text, and JSON or YAML files.
  • A Numeric flag supports integers.

List of feature flags
List of feature flags

Create a feature flag

To create a feature flag, complete these steps:

  1. In the App Configuration console, click Features flags.

  2. Select the Current Environment to display the list of feature flags in that environment.

  3. Click Create. The side panel opens with fields for creating a new feature flag.

    Create feature flag
    Creating a new feature flag

  4. Provide the feature flag details:

    • Name - name of the feature flag.
    • Feature flag ID - the feature flag ID value is auto suggested based on the entered feature name. You can modify the same, if needed. Use the Feature flag ID value as the identifier in your SDK or API code.
    • Flag type - specify the type of the feature flag. Supported type includes: Boolean, String, and Numeric. For more information about flag type and default values, see Selecting feature flag type.
    • Default value - specify the default value for the feature flag type selected. For more information about flag type and default values, see Selecting feature flag type.
    • Optionally, select a collection for applying a feature flag now. Otherwise, you need to add a collection before you toggle a feature flag. You can add the feature flag to one or more collections by selecting in the Flag availability across collections list.
    • Feature rollout - specify the Rollout percentage by using the slider. For more information about percentage rollout, see Configure feature rollout percentage.
    • Description - add a description of the feature flag, which is optional.
    • Optionally, define Tags that help you to identify the feature flag.
  5. Click Create.

By default, when you create a new feature flag, the Enabled toggle switch is set to OFF.

Selecting feature flag type

You can have one of the following flag types that is associated to a feature flag:

  • Boolean
  • String
  • Numeric

Each of the Flag type is having a default value.

  • When you set the toggle switch to ON, the value for the Enabled value is required, which can be overridden when targeting to a segment.
  • When you set the toggle switch to OFF, the value for the Disabled value is required, which can be overridden when targeting to a segment.

Boolean

When you select the Flag type as Boolean, the Default value details are displayed:

Feature flag type - Boolean
Feature flag type - Boolean

  1. Select the Enabled value from the list. This value is returned by default when the toggle switch is set to ON for the feature flag. This value can be overridden when targeting to a segment.

  2. Select the Disabled value from the list. This value is returned by default when toggle switch is set to OFF for the feature flag.

String

When you select the Flag type as String, the Default value details are displayed:

Feature flag type - String
Feature flag type - String

  1. Select the Format of the string flag type from the list. Supported format is Text, JSON, and YAML. When JSON or YAML format is selected, provide the Enabled value and Disabled value in the selected format.

  2. Specify the Enabled value. This value is returned by default when toggle switch is set to ON for the feature flag. This value can be overridden when targeting to a segment.

  3. Specify the Disabled value. This value is returned by default when toggle switch is set to OFF for the feature flag.

Numeric

When you select the Flag type as Numeric, the Default value details are displayed:

Feature flag type - Numeric
Feature flag type - Numeric

  1. Select the Enabled value from the list. Only integer values are supported. This value is returned by default when toggle switch is set to ON for the feature flag. This value can be overridden when targeting to a segment.

  2. Select the Disabled value from the list. Only integer values are supported. This value is returned by default when toggle switch is set to OFF for the feature flag.

Target collections to feature flags

Optionally, select a collection for applying a feature flag now. Otherwise, you need to add a collection before you toggle a feature flag. You can add feature flags to one or more collections either during creation of feature flag or during editing feature flag details.

For adding collections to the feature flag, for the Flag availability across collections field, select the collection from the list.

If you try to target a feature flag that is not linked to a collection, a window is displayed to add a feature flag to a collection.

Configure feature rollout percentage

You can configure the feature flag with a rollout percentage in the range of 0 to 100, denoting the applicability of the feature to a partial set of users or devices.

Percentage rollout helps to enable a feature to a small percentage of random users or subset of entities, providing more control on the release cycle and achieve progressive delivery. When you are confident on the feature that you want to roll out is working as intended, increase the percentage over time.

Percentage rollout uses a hashing algorithm that generates a hash based on the rule set. This hash is used by the SDK to generate a percentage value for that user. The percentage value generated for that user is compared to the value set for the percentage rollout value, determines whether the user is eligible to receive that feature or not.

For example, the hash has partitions from 1 to 100,000. When you assign a feature flag, the hash assigns values from 1 to 100,000 to users in each partition. For example, when you assign 25% to a feature flag, App Configuration SDK delivers that feature to hash partitions from 1 to 25,000. If you change the percentage of users receiving that feature from 25% to 50%, partitions 25,001 to 50,000 would be added to the set of partitions already receiving that feature.

Percentage rollout capability is available for Lite and Enterprise plans.

Following are some of the percentage rollout scenarios:

  • If the feature flag is disabled, then SDK returns the default Disabled value.
  • If the feature flag is enabled without any segment rules and no percentage rollout is set, then the SDK returns default Enabled value.
  • If the feature flag is enabled without any segment rule and percentage rollout is set to 0%, then the SDK returns Disabled value for all users.
  • If the feature flag is enabled without any segment rule and percentage rollout is set to a percent, say 50%, then the SDK checks if the user belongs to the configured percentage rollout size, if the user belongs to the rollout criteria, then the SDK returns the Enabled value. If the user doesn't belong to the rollout criteria, then the SDK returns the Disabled value.
  • If the feature flag is enabled with segment rules, then SDK first evaluates the user against the configured rules. If user is part of the configured rule, then the SDK evaluates if the user is eligible for percentage rollout.
    • If multiple rules are configured and the user is checked for rule match until the first match. If no match found, then the SDK evaluates against the default rollout.
    • If the user is evaluated to be part of the segment and the segment percentage rollout is 0%, then even if the user is part of the segment, user will not receive the segment value. The SDK returns the default Disabled value.
    • If the user is evaluated to be part of the segment and the segment percentage rollout is set to a percentage, say 50%, then the SDK checks if the user belongs to configured rollout size, if the user belongs to the rollout criteria, then the SDK returns the segment overriding value. If the user doesn't belongs to the rollout criteria, then the SDK returns Disabled value.

View as table

Percentage rollout scenarios
Feature Flag Is targeting configured? Percentage
rollout
Is user
part of
configured segment
Is user
part of
percentage rollout
criteria
Value
returned
by SDK
Disabled NA Any % rollout set NA NA Disabled value
Enabled No 0% NA No Disabled value
Enabled Yes 0% Yes No Disabled value
Enabled Yes 0% No No Disabled value
Enabled No Between 0% to 100% NA Yes Enabled value
Enabled No Between 0% to 100% NA No Disabled value
Enabled Yes Betweeen 0% to 100% Yes Yes Overriden value
Enabled Yes Betweeen 0% to 100% Yes No Disabled value
Enabled Yes Between 0% to 100% No Yes Enabled value
Enabled Yes Between 0% to 100% No No Disabled value
Enabled No 100% NA Yes Enabled value
Enabled Yes 100% Yes Yes Overriden value
Enabled Yes 100% No Yes Enabled value

Targeting a segment with a feature flag

You can roll out feature flags to one or more target segments. You can set different flag values for different segments, if needed.

  1. From the App Configuration console, go to Feature flags. This pane displays the list of feature flags available in the current environment of the App Configuration service instance.

  2. Click Add targeting in the required feature flag row to display the Add targeting configurations side-panel.

  3. The Feature rollout (Default) section displays the default Rollout percentage slider defined when creating the feature flag. You can adjust the rollout percentage value by moving the slider. Changes are saved automatically as you adjust the slider.

  4. In the Rules section, you can define rules that control who sees your feature, and manage multiple rules with ease. The initial view shows the Create Rule button and a search field to filter existing rules.

    Adding a Rule
    Adding a rule

    When creating the rule specify the following:

    • Rule Name - Enter a descriptive name for the rule (maximum 100 characters).

    • Rule ID - Enter a unique identifier for the rule. This must contain only letters, numbers, dots (.), hyphens (-), and underscores (_). Maximum 100 characters.

    • In the Rollout percentage, you can define the value as Override or Inherit from default. If the Override option is selected, adjust the Rollout percentage value by using the slider. The percentage is saved automatically as you adjust the slider.

    • Select segments - Choose one or more segments from the list. The selected segments are displayed with a count indicator (e.g., "1 × segment is selected"). If no segments are available to target, click Create segment. For more information about creating a segment, see Create a segment.

    • For the Enabled value, you can select Override and modify the value or select Inherit from flag.

    • Priority - Set the rule priority to determine the order in which rules are evaluated. You can set the priority to one of the following options:

      • Set to Bottom - Sets the priority of the rule to last. This is the default option.
      • Set to Top - Sets the priority to the top of the rules (i.e. 1).
      • Specific Position - Sets the priority to specific user defined position. (Priority number can be between 1 to number of rules).

    The rule is created and saved when you click Save Rule. There is no separate Create or Cancel button - simply close the panel when you're done configuring the rule.

  5. After creating a rule, it appears in the rules table showing Priority, Rule Name, Segments, and Rollout information. You can perform the following actions for each rule by using the overflow menu :

    • Copy - Create a new rule by duplicating an existing rule.

    Copy Rule overflow menu
    Copy Rule overflow menu

    Copy rule view
    Copy rule view

    • Edit rule - Modifies an existing rule configuration.

    Edit rule overflow menu
    Edit rule overflow menu

    Edit rule view
    Edit rule view

    • Edit priority - Change the rule evaluation order. Priority determines the order in which rules are evaluated. Rules with a lower priority number are evaluated first. You can set the priority to one of the options mentioned previously.

    Edit priority overflow menu
    Edit priority overflow menu

    Edit priority rule view
    Edit priority rule view

    • Delete - Remove the rule. When you select delete, a confirmation dialog appears to prevent accidental deletion.

    Delete rule overflow menu
    Delete rule overflow menu

    Delete confirmation dialog
    Delete rule confirmation dialog

If you try to target a feature flag that is not linked to a collection, a window is displayed to add a feature flag to a collection.

Enabling a feature flag

After you target a feature flag to a segment, click the toggle (ON/OFF) to enable or disable a feature flag.

Feature flags - overflow menu

The overflow menu for each of the feature flag (three vertical dots) consists of Edit, Copy, and Delete operations and Remove targeting for those feature flags that are already targeted.

Overflow menu for a feature flag
Overflow menu for a feature flag

  • When Edit option is selected, you can change the Name, Description, add or delete Tags, change the Flag type and Default value, and add or remove collections for the Flag availability across collections field information.
  • When Copy option is selected, the feature flag information is copied, and you need to modify the Name of the feature flag. Optionally, modify the other details based on your need.
  • When Delete option is selected, a confirmation window is displayed to seek confirmation to delete the selected feature flag. Deleting option permanently deletes the feature flag and the action cannot be undone.
  • In the list of feature flags, in a feature flag, when Copy to clipboard icon is clicked, the feature flag's Feature flag ID value is copied to the clipboard.
  • Remove targeting removes the targeting of feature flags to a segment.