Skip to main content

Add and manage target groups

note

While targets are often users, a target can be anything that can be uniquely identified. For example, a target can be a user, an application, a system, a machine, or any resource uniquely identified by an IP address, email ID, user ID, etc.

Target groups are a collection of targets that allow you to serve Feature Flag Variations to a list of users in bulk. You can group targets into a group either by picking individual targets or by defining rules that automatically map targets to a target group. For example, you can add individual targets joe@harness.io and jane@harness.io to the QA internal users group or you can define a rule that all the emails ending with @harness.io are added to the QA internal users group.

You can also do the opposite and exclude specific targets from a target group.

This topic describes how to add a target group to your Environment, add targets to the group, and apply the target group to a Feature Flag.

Watch this video for an introduction to target groups:

Before you begin

Make sure you've created targets to add to the target group.

Create a target group

To create a target group:

  1. In Feature Flags, click Target Management, then click Target Groups.
  2. Click + New Target Group.
  3. In Create a Target Group, enter a Name for your group and click Create.
  4. (Optional) In Description, add a description of the group.

After you have created a target group, you need to add targets to it. You can add targets to a target group by selecting them individually or by setting conditions to add all targets that meet those criteria.

Add targets from the Target Groups page

You can add individual targets from the Targets page or the Target Groups page.

  1. In Target Management, in Target Groups, select the target group you want to add targets to.

    A screenshot of the Target Management page with a target group highlighted

  2. In Criteria, click Edit.

The edit button next to Criteria.
  1. From here, you can include or exclude specific targets, or you can set rules to add targets based on conditions you set.

Include or exclude specific targets

  • To add specific targets, in Include the following, select the targets.

  • To exclude targets, in Exclude the following, select the targets.

    A screenshot of targets added to the Target Group Criteria.

Add targets based on conditions

note

When you create a target based on Conditions, on the target overview page the group isn't displayed under the Target Groups column.

In addition to targeting individual users, Harness Feature Flags also allows you to target a group based on the conditions you set. You can add conditions by constructing rules using the following:

  • The name or identifier of the target.
  • An operator.
  • Text that must match the target name or identifier.

The following operators are supported:

OperatorAttribute TypeDefinition
starts withStringMatches the prefix of a string. If you enter multiple string values, only the first is matched.
ends withStringMatches the suffix of a string. If you enter multiple string values, only the first is matched.
containsStringMatches a part of a string. If you enter multiple string values, only the first is matched.
equalsNumber or stringMatches the string or number. If you enter multiple string values, only the first is matched.
equals (sensitive)Number or stringMatches the number or string and is case-sensitive. If you enter multiple string values, only the first is matched.For example,  the string HELLO is different from the string hello. 
inNumber or stringActs as an “or” operator, so you can add multiple values at once.

For example, you could set a rule to add all targets whose identifiers end in @harness.io.

To add targets based on conditions:

  1. In Target Group Criteria, click + Add Rule.
  2. In the first drop-down menu, select whether the condition applies to the Target Name or Identifier.
  3. In the second drop-down menu, select the operator to apply to the Target Name or Identifier.
  4. In the search bar, enter the value you want the Target Name or Identifier to match and click the + button to add it. The following shows an example of a rule that adds all targets with a Target Identifier ending in harness.io to the target group.
An example of the target group Criteria page with a condition added.
  1. Click Save. Targets that meet the criteria are now included in the target group.
The Target Groups page with the new condition displayed.

When you add targets based on conditions, on the Target Management:Targets page, the target group is notdisplayed in the Target Groups column.

Add or exclude targets from target settings

You can use Target Settings to include or exclude targets from a target group. Complete the following steps to include or exclude targets using the Target Settings:

  1. Go to Target Management > Targets, and then click the target you want to add to a group.

  2. Click Target Groups, and then select either or both of the following:

    • Add to Target Groups to add a this target to groups

    • Exclude from Target Groups to exclude a specific target

      A screenshot of a target with the Target Groups tab opened.

    You can add or exclude the target to multiple groups at once.

  3. Select the group(s) to add or exclude a target to/from, then click Add to Target Group, or Exclude from Target Group.

  4. The targets are now added to, or excluded from, the target groups.

Targeting using AND rules (beta feature)

note

This beta feature is behind the FFM_11173_TARGET_GROUP_AND_OPERATOR feature flag. AND rules won't be available via the UI or work with sdks or the relay proxy unless this flag is enabled on Harness SaaS.

Contact Harness Support to enable this feature.

SDK compatiblity

SDKCompatible VersionsOther Config Required?
Golangv0.1.24+
.NETv1.6.10+
Javav1.6.1+
Pythonv1.6.2+
Node.jsv1.8.2+
Rubyv1.3.1+
Erlangn/a
Apexn/a
JavascriptAll
Android/IOSAll
ReactAll
React NativeAll
FlutterAll
XamarinAll
Relay Proxy V22.0.1+Enable and-rules flag in your relay proxy - see here

Creating AND rules

A screenshot showing target group AND rules
  1. Click into the target group you want to add rules for
  2. Click ‘edit’ beside criteria to open the side panel to add rules
  3. Click ‘Add rule’ to add a new OR rule
  4. Click the + sign beside an existing rule to add an AND condition to a rule

Behavior with compatible SDKs

The AND rule will be used to evaluate the flag i.e. the flag in the example will only be true if (Identifier equals Harness AND loc equals US) OR (Identifier equals Test_Acc)

Behavior with older SDKs

Older SDKs don’t have the logic to handle the AND section of each rule. They will only evaluate the first clause of each rule i.e. for the above example older non compatible SDK’s will evaluate the rule as (Identifier equals Harness) OR (Identifier equals Test_Acc). The same behaviour applies when the FFM_11173_TARGET_GROUP_AND_OPERATOR flag is disabled.

Backwords/forwards compatibility

These AND rules are backwards and forwards compatible with existing target group rules. When the FFM_11173_TARGET_GROUP_AND_OPERATOR flag is enabled all your existing OR rules will still exist, you’ll just now have the ability to add the additional AND rules to them via the + symbol in the updated UI.

If for any reason you need the flag to be disabled in future all newly created rules will still exist, however they will only display the first clause of each rule i.e. if you rolled back to the old UI/functionality you would only see 2 rules in the UI for this example, Identifier equals Harness OR Identifier equals Test_Acc, the AND portions would be dropped.

Next step

After you have added the targets and target groups, you can then use them on your Feature Flags.