Skip to content

Commit 36450ef

Browse files
ruai0511kolchfa-awsnatebower
authored
Add principal attributes description to Rule-based Auto-tagging documentation (#11158)
* add security attributes description to auto tagging documentation Signed-off-by: Ruirui Zhang <[email protected]> * Doc review Signed-off-by: Fanit Kolchina <[email protected]> * Apply suggestions from code review Signed-off-by: Nathan Bower <[email protected]> --------- Signed-off-by: Fanit Kolchina <[email protected]> Signed-off-by: Nathan Bower <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]> Co-authored-by: Nathan Bower <[email protected]>
1 parent 0b445f3 commit 36450ef

File tree

4 files changed

+88
-21
lines changed

4 files changed

+88
-21
lines changed

_tuning-your-cluster/availability-and-recovery/rule-based-autotagging/autotagging.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Rule-based auto-tagging provides a flexible framework for implementing feature-s
2929
Before reviewing the rule configuration and behavior, it's important to understand the following key components of rule-based auto-tagging:
3030

3131
* **Rule**: Defines matching criteria (attributes) and the value to assign.
32-
* **Attributes**: Key-value pairs used to match rules (such as index patterns, user roles, or request types).
32+
* **Attributes**: Key-value pairs used to match rules (such as index patterns, username, user roles, or request types).
3333
* **Feature-specific value**: The value assigned when a rule matches.
3434
* **Pattern matching**: The matching behavior (exact or pattern based) for attribute values.
3535

@@ -44,7 +44,11 @@ The following rule schema includes matching attributes and a feature-specific va
4444
```json
4545
{
4646
"_id": "fwehf8302582mglfio349==",
47-
"index_pattern": ["logs-prod-*"],
47+
"index_pattern": ["logs-prod-*"],
48+
"principal": {
49+
"username": ["admin"],
50+
"role": ["all_access"]
51+
},
4852
"other_attribute": ["value1", "value2"],
4953
"workload_group": "production_workload_id",
5054
"updated_at": 1683256789000
@@ -92,7 +96,38 @@ OpenSearch evaluates incoming requests using the following process:
9296
3. The most specific matching rule's value is assigned.
9397
4. If no rules match, no value is assigned.
9498

95-
## Examples
99+
### Rule matching examples
100+
101+
The following examples demonstrate how OpenSearch matches attributes and resolves ties between rules.
102+
103+
In these examples, the `username` attribute has higher priority than the `index_pattern` attribute (priority order depends on the feature and feature type).
104+
105+
1. **Example 1**
106+
A request matches three rules:
107+
108+
* Rule 1: `index_pattern = log`
109+
* Rule 2: `username = admin`
110+
* Rule 3: `index_pattern = log123`
111+
112+
**Result**: Rule 2 applies because the `username` attribute has higher priority.
113+
114+
2. **Example 2**
115+
A request matches two rules:
116+
117+
* Rule 1: `index_pattern = logs-prod-*`
118+
* Rule 2: `index_pattern = logs-*`
119+
120+
**Result**: Rule 1 applies because `logs-prod-*` is more specific than `logs-*`.
121+
122+
3. **Example 3**
123+
A request matches two rules:
124+
125+
* Rule 1: `index_pattern = log` and `username = admin`
126+
* Rule 2: `username = admin`
127+
128+
**Result**: Rule 1 applies because it includes both the `index_pattern` and `username` attributes, making it a more specific match.
129+
130+
## Workload management examples
96131

97132
These examples demonstrate how rule-based auto-tagging works in workload management, which uses index patterns as its primary attribute.
98133

@@ -167,7 +202,7 @@ When creating rules, the following issues can occur:
167202

168203
* **Unexpected value**: This can happen when multiple rules are defined with overlapping or conflicting conditions.
169204
For example, consider the following rules:
170-
1. `{ "username": ["dev*"], "index_pattern": ["logs*"] }`
205+
1. `{ principal: {"username": ["dev*"]}, "index_pattern": ["logs*"] }`
171206
2. `{ "index_pattern": ["logs*", "events*"] }`
172207

173208
If a user with the username `dev_john` sends a search request to `logs_q1_25`, it will match the first rule based on the `username` and `index_pattern` attributes. The request will not match the second rule, even though the `index_pattern` also qualifies.

_tuning-your-cluster/availability-and-recovery/rule-based-autotagging/rule-lifecycle-api.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The following sections describe the API endpoints available for managing rules a
1717

1818
### Create a rule
1919

20-
Use the followiing endpoint to add a new rule for a specific feature type:
20+
Use the following endpoint to add a new rule for a specific feature type:
2121

2222
```json
2323
PUT /_rules/{feature_type}
@@ -85,13 +85,17 @@ The following example demonstrates how to use the Rules API to create a rule.
8585

8686
### Create a rule
8787

88-
The following request creates a rule that assigns a `workload_group` value based on matching `index_pattern` attributes:
88+
The following request creates a rule that assigns a `workload_group` value based on matching `index_pattern` and principal attributes:
8989

9090
```json
9191
PUT _rules/workload_group
9292
{
9393
"description": "description for rule",
9494
"index_pattern": ["log*", "event*"],
95+
"principal": {
96+
"username": ["admin"],
97+
"role": ["all_access"]
98+
},
9599
"workload_group": "EITBzjFkQ6CA-semNWGtRQ"
96100
}
97101
```
@@ -106,6 +110,10 @@ PUT _rules/workload_group/0A6RULxkQ9yLqn4r8LPrIg
106110
{
107111
"description": "updated_description for rule",
108112
"index_pattern": ["log*"],
113+
"principal": {
114+
"username": ["admin"],
115+
"role": ["all_access"]
116+
},
109117
"workload_group": "EITBzjFkQ6CA-semNWGtRQ"
110118
}
111119
```
@@ -130,10 +138,10 @@ GET /_rules/{feature_type}
130138
```
131139
{% include copy-curl.html %}
132140

133-
The following request returns all rules of the feature type `workload_group` that contain the attribute `index_pattern` with values `a` or `b`:
141+
The following request returns all rules of the `workload_group` feature type that contain an `index_pattern` attribute with values `a` or `b` and `principal.username` set to `admin`:
134142

135143
```json
136-
GET /_rules/workload_group?index_pattern=a,b
144+
GET /_rules/workload_group?index_pattern=a,b&principal.username=admin
137145
```
138146
{% include copy-curl.html %}
139147

@@ -160,6 +168,10 @@ GET /_rules/workload_group?index_pattern=a,b&search_after=z1MJApUB0zgMcDmz-UQq
160168
"id": "wi6VApYBoX5wstmtU_8l",
161169
"description": "description for rule",
162170
"index_pattern": ["log*", "event*"],
171+
"principal": {
172+
"username": ["admin"],
173+
"role": ["all_access"]
174+
},
163175
"workload_group": "EITBzjFkQ6CA-semNWGtRQ",
164176
"updated_at": "2025-04-04T20:54:22.406Z"
165177
}
@@ -181,6 +193,10 @@ GET /_rules/workload_group?index_pattern=a,b&search_after=z1MJApUB0zgMcDmz-UQq
181193
"id": "z1MJApUB0zgMcDmz-UQq",
182194
"description": "Rule for tagging workload_group_id to index123",
183195
"index_pattern": ["index123"],
196+
"principal": {
197+
"username": ["admin"],
198+
"role": ["all_access"]
199+
},
184200
"workload_group": "workload_group_id",
185201
"updated_at": "2025-02-14T01:19:22.589Z"
186202
},

_tuning-your-cluster/availability-and-recovery/workload-management/workload-group-rules.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ Workload group rules allow you to automatically assign workload group IDs to inc
1414

1515
## Creating a rule
1616

17-
To create a rule for a workload group, provide the workload group ID in the `workload_group` parameter. The following request creates a rule that assigns the specified workload group to requests for the matching `index_pattern`:
17+
To create a rule for a workload group, provide the workload group ID in the `workload_group` parameter. The following example creates a rule that assigns the given workload group to requests matching both the `index_pattern` and `principal.username` attributes:
1818

1919
```json
2020
PUT _rules/workload_group
2121
{
2222
"description": "description for rule",
2323
"index_pattern": ["test*"],
24+
"principal": {
25+
"username": ["admin"]
26+
},
2427
"workload_group": "wfbdJoDAS0mYiLbEAjd1sA"
2528
}
2629
```
@@ -32,23 +35,36 @@ The response contains the rule ID:
3235
{
3336
"id": "176fd554-43e7-39eb-92cc-56615d287eae",
3437
"description": "description for rule",
35-
"index_pattern": [
36-
"test*"
37-
],
38+
"index_pattern": ["test*"],
39+
"principal": {
40+
"username": ["admin"]
41+
},
3842
"workload_group": "wfbdJoDAS0mYiLbEAjd1sA",
3943
"updated_at": "2025-08-06T15:12:44.791Z"
4044
}
4145
```
4246

47+
## Attributes
48+
49+
The `workload_group` feature type contains the following attributes. Each rule must contain at least one of these attributes.
50+
51+
The table lists the attributes in order of priority, from highest to lowest. This priority is predefined and cannot be changed by the user. When multiple rules match a request, the rule containing the highest-priority attribute is applied.
52+
53+
| Attribute | Data type | Description |
54+
|:---------------------|:----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
55+
| `principal.username` | List | A list of usernames to be matched to this rule. This attribute is available only when the Security plugin is enabled on the domain. The attribute supports exact matching only. |
56+
| `principal.role` | List | A list of roles to be matched to this rule. This attribute is available only when the Security plugin is enabled on the domain. The attribute supports exact matching only. |
57+
| `index_pattern` | List | A list of target indexes for incoming queries. Each element can be a full index name or a prefix ending in `*` to support wildcard matching (for example, `logs*`). |
58+
4359
## Parameters
4460

45-
The `workload_group` feature type requires the following parameters.
61+
The `workload_group` feature type contains the following parameters.
4662

47-
| Attribute | Data type | Description |
48-
| :--- | :--- | :--- |
49-
| `index_pattern` | List | A list of strings used to match the target indexes of incoming queries. Each string can be an exact index name or a prefix ending in `*` to support wildcard matching, for example, `logs*`. |
50-
| `description` | String | A description of the rule. |
51-
| `workload_group` | String | The workload group ID to apply to the requests matching this rule. |
63+
| Parameter | Data type | Description |
64+
|:-----------------|:----------|:--------------------------------------------------------------------------------------------------------|
65+
| attribute | Object | A rule must contain at least one attribute (`index_pattern`, `principal.username`, or `principal.role`). |
66+
| `description` | String | A description of the rule. |
67+
| `workload_group` | String | The workload group ID to apply to the requests matching this rule. |
5268

5369
## Updating a rule
5470

@@ -96,10 +112,10 @@ GET /_rules/workload_group/{rule_id}
96112
```
97113
{% include copy-curl.html %}
98114

99-
The following request retrieves all `workload_group` rules matching the specified `index_pattern`:
115+
The following request retrieves all `workload_group` rules matching the specified `index_pattern` and `principal.username`:
100116

101117
```json
102-
GET /_rules/workload_group?index_pattern=log*,event*
118+
GET /_rules/workload_group?index_pattern=log*,event*&principal.username=admin
103119
```
104120
{% include copy-curl.html %}
105121

_tuning-your-cluster/availability-and-recovery/workload-management/workload-groups.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GET /_wlm/workload_group/{name}
9696
To delete a workload group, specify its name as a path parameter:
9797

9898
```json
99-
DELETE /_wlm/query_group/{name}
99+
DELETE /_wlm/workload_group/{name}
100100
```
101101
{% include copy-curl.html %}
102102

0 commit comments

Comments
 (0)