Add and manage target groups
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:
- In Feature Flags, click Target Management, then click Target Groups.
- Click + New Target Group.
- In Create a Target Group, enter a Name for your group and click Create.
- (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.
-
In Target Management, in Target Groups, select the target group you want to add targets to.
-
In Criteria, click Edit.
- 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.
Add targets based on conditions
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:
Operator | Attribute Type | Definition |
starts with | String | Matches the prefix of a string. If you enter multiple string values, only the first is matched. |
ends with | String | Matches the suffix of a string. If you enter multiple string values, only the first is matched. |
contains | String | Matches a part of a string. If you enter multiple string values, only the first is matched. |
equals | Number or string | Matches the string or number. If you enter multiple string values, only the first is matched. |
equals (sensitive) | Number or string | Matches 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. |
in | Number or string | Acts 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:
- In Target Group Criteria, click + Add Rule.
- In the first drop-down menu, select whether the condition applies to the Target Name or Identifier.
- In the second drop-down menu, select the operator to apply to the Target Name or Identifier.
- 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.
- Click Save. Targets that meet the criteria are now included in the target group.
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:
-
Go to Target Management > Targets, and then click the target you want to add to a group.
-
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
You can add or exclude the target to multiple groups at once.
-
-
Select the group(s) to add or exclude a target to/from, then click Add to Target Group, or Exclude from Target Group.
-
The targets are now added to, or excluded from, the target groups.
Targeting using AND rules (beta feature)
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
SDK | Compatible Versions | Other Config Required? |
---|---|---|
Golang | v0.1.24+ | |
.NET | v1.6.10+ | |
Java | v1.6.1+ | |
Python | v1.6.2+ | |
Node.js | v1.8.2+ | |
Ruby | v1.3.1+ | |
Erlang | n/a | |
Apex | n/a | |
Javascript | All | |
Android/IOS | All | |
React | All | |
React Native | All | |
Flutter | All | |
Xamarin | All | |
Relay Proxy V2 | 2.0.1+ | Enable and-rules flag in your relay proxy - see here |
Creating AND rules
- Click into the target group you want to add rules for
- Click ‘edit’ beside criteria to open the side panel to add rules
- Click ‘Add rule’ to add a new OR rule
- 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.