You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/manage/users-roles/roles/construct-search-filter-for-role.md
+37-57Lines changed: 37 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,52 +5,20 @@ description: Construct a role search filter to control what log data users with
5
5
---
6
6
7
7
import useBaseUrl from '@docusaurus/useBaseUrl';
8
-
8
+
import RoleStacking from '../../../reuse/role-stacking-tip.md';
9
9
10
10
This page describes how to define search filters for a role. These instructions apply to the **Search Filter** option in Step 6 of the [Create a role](/docs/manage/users-roles/roles/create-manage-roles/#create-a-role) procedure.
11
-
12
-
## Understanding search filters
13
-
14
-
A search filter for a role defines what log data a user with that role can access. You can define a search filter using keywords, wildcards, metadata fields, and logical operators. Here is a simple role filter:
15
-
16
-
```sql
17
-
_sourceCategory=labs*
18
-
```
19
-
20
-
This filter grants access to logs whose `_sourceCategory` begins with the string “labs”. (Logs whose `_sourceCategory` don’t start with “labs” won’t be accessible.)
The example above positively grants access to log data. You can do the opposite: explicitly deny access to data, with an exclamation point (!). For example:
35
-
36
-
```
37
-
!_sourceCategory=JobX*
38
-
```
39
-
40
-
The role filter above denies access to log data whose `_sourceCategory` begins with “JobX”. (Access to log data with other source category values is not restricted.)
41
-
42
-
The examples above are simple: they involve a single role, and hence a single role filter.
43
-
44
-
Typically however, a Sumo user will have multiple roles. If a user has multiple roles, Sumo `OR`s the several role filters and prepends that expression to the user’s queries with an `AND`, as discussed in [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
45
11
46
12
## Search filter basics
47
13
48
-
The sections below list search filter limitations, and describe how you can use keywords, wildcards,metadata, and logical operators in filters.
14
+
A search filter for a role defines what log data a user with that role can access. You can define a search filter using keywords, wildcards,metadata fields, and logical operators.
49
15
50
-
The explanations of the behavior of each example filter assume that no other role filters apply. In practice, you will likely assign multiple roles to users. After you understand the basics of how role filters work, see [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
16
+
The explanations of the behavior of each example filter assume that no other role filters apply. In practice, you may assign multiple roles to users. After you understand the basics of how role filters work, see [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
51
17
52
18
### Search filter limitations
53
19
20
+
The sections below list search filter limitations, and describe how you can use keywords, wildcards, metadata, and logical operators in filters.
21
+
54
22
* Role filters should include only keyword expressions or built-in metadata field expressions using these fields: `_sourcecategory`, `_collector`, `_source`, `_sourcename`, `_sourcehost`.
55
23
* Using `_index` or `_view` in a role filter scope is not supported.
56
24
* Role filters cannot include vertical pipes (`|`).
@@ -69,33 +37,33 @@ You can use metadata fields in a role search filter. The following search filter
69
37
_collector=HR_Tools
70
38
```
71
39
72
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
40
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
73
41
74
42
```sql
75
43
_collector=HR_Tools AND<user-query>
76
44
```
77
45
78
46
### Using AND and OR in a search filter
79
47
80
-
You can use AND and OR in a search filter. For example, this role filter uses OR to grant access to log data from two source categories:
48
+
You can use `AND` and `OR` in a search filter. For example, this role filter uses `OR` to grant access to log data from two source categories:
81
49
82
50
```sql
83
51
_sourceCategory=stock OR _sourceCategory=insurance
84
52
```
85
53
86
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
54
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
87
55
88
56
```sql
89
57
(_sourceCategory=stock OR _sourceCategory=insurance) AND<user-query>
90
58
```
91
59
92
-
This role filter below uses AND to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
60
+
This role filter below uses `AND` to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
93
61
94
62
```sql
95
63
_collector=HR_Tools AND _sourceCategory=insurance
96
64
```
97
65
98
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
66
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
99
67
100
68
```sql
101
69
(_collector=HR_Tools AND _sourceCategory=insurance) AND<user-query>
@@ -109,7 +77,7 @@ You can include a string you want to search for in a role search filter. This ro
109
77
_collector=HR_Tools AND enrollment
110
78
```
111
79
112
-
When a user with that role filter runs a query, Sumo runs it like this:
80
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
113
81
114
82
```sql
115
83
(_collector=HR_Tools AND enrollment) AND<user-query>
@@ -123,7 +91,7 @@ You can use an asterisk (\*) as a wildcard in a role search filter. This role fi
123
91
_collector=HR*
124
92
```
125
93
126
-
When a user with that role filter runs a query, Sumo runs it like this:
94
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
127
95
128
96
```sql
129
97
_collector=HR*AND<user-query>
@@ -135,7 +103,7 @@ This role filter grants access to logs that contain the string “violation” f
135
103
_collector=HR*AND violation
136
104
```
137
105
138
-
When a user with that role filter runs a query, Sumo runs it like this:
106
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
139
107
140
108
```sql
141
109
(_collector=HR*AND violation) AND<user-query>
@@ -155,15 +123,21 @@ denies access to log data whose:
155
123
*`_sourceName` contains “finance”
156
124
*`_sourceCategory` contains “secret”
157
125
158
-
When a user with that role filter runs a query, Sumo runs it like this:
126
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
Although this example demonstrates that filtering to deny access is possible, we do not recommend it. If a user has multiple roles, one role may deny access to an area while another grants access, leading to conflicts. To avoid this, use filtering to allow access rather than deny it. This ensures roles work additively, making access management more predictable.
134
+
:::
135
+
164
136
## Multiple role filters and filter precedence
165
137
166
-
When a user is assigned to multiple Sumo roles, Sumo combines the role filters from each of the roles using a logical OR to come up with the combined role filter.
138
+
When a user is assigned to multiple Sumo Logic roles ("role stacking"), Sumo Logic combines the role filters from each of the roles using a logical `OR` to come up with the combined role filter.
139
+
140
+
<RoleStacking/>
167
141
168
142
When multiple roles filters are applied to a query, the least restrictive filter takes precedence. That this rule doesn’t apply if any of the role filters applied to a query is simply blank, which effectively grants access to all data, and would be the least restrictive filter. If the combined search filters applied to a query includes filters that are blank, the blank search filter is ignored and the next least restrictive filter takes precedence. So, if you actually want to grant a role access to all data, set the search filter to an asterisk (`*`). A search filter that is configured in that fashion will take precedence when combined with more restrictive search filters.
169
143
@@ -180,7 +154,7 @@ Role A allows access to log data whose `_source` tag is “GCP Audit” and `_co
180
154
181
155
Role B Allows access to log data whose `_sourceCategory` tag begins with “Vx”.
182
156
183
-
When a user with Roles A and B runs a query, Sumo applies the filters with an OR, and prepends them with an AND to your query, like this:
157
+
When a user with Roles A and B runs a query, Sumo Logic applies the filters with an `OR`, and prepends them with an `AND` to your query, like this:
184
158
185
159
```sql
186
160
((_source="GCP Audit"AND _collector="GCP") OR _sourceCategory="Vx*")
@@ -196,19 +170,19 @@ Assume the following role filters.
196
170
| Role | Filter |
197
171
|:----------|:-------------------|
198
172
| Role A |`_collector=fee*`|
199
-
| Role B |`!_collector=fi*`|
173
+
| Role B |`_collector=f*`|
200
174
201
175
Role A allows access only to log data whose `_collector` tag matches “fee\*”, and not to data whose `_collector` tag is any other value.
202
176
203
-
Role B Allows access to any log data whose `_collector` tag does not match “fi”.
177
+
Role B Allows access to any log data whose `_collector` tag matches “f\*”, and not to data whose `_collector` tag is any other value.
204
178
205
-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, and prepends them with an AND to your query, like this:
179
+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, and prepends them with an `AND` to your query, like this:
206
180
207
181
```sql
208
-
(_collector=fee OR!_collector=fi) AND<your-query>
182
+
(_collector=fee OR _collector=f) AND<your-query>
209
183
```
210
184
211
-
**The least restrictive of the role filters takes precedence**. So, although Role A effectively restricts results to log data that matches `_collector=fee*`, Role B allows grants access to all collectors, except for those that match `_collector=fi*`. So, Role B takes precedence and Role A has no effect.
185
+
**The least restrictive of the role filters takes precedence**. So, although Role A effectively restricts results to log data that matches `_collector=fee*`, Role B allows grants access to all collectorsthat match `_collector=f*`. So, Role B takes precedence and Role A has no effect.
212
186
213
187
### Example 3
214
188
@@ -224,14 +198,15 @@ Role A allows access only to log data whose `_sourceCategory` is “analytics-la
224
198
225
199
Role B Allows access to log data whose `_sourceCategory` begins with “analytics”.
226
200
227
-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, like this:
201
+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, like this:
228
202
229
203
```sql
230
204
(_sourceCategory=analytics-lab OR _sourceCategory=analytics*) AND<your-query>
231
205
```
232
206
233
207
**The least restrictive of the role filters takes precedence.** Role A alone grants access to a log data from a single source category, “analytics-lab”. Role B grants access to log data to any source category that starts with “analytics”. Since the least restrictive filter takes precedence, data tagged `_sourceCategory=analyticsLong` could be returned in addition to data tagged `_sourceCategory=analytics-lab`.
234
208
209
+
<!-- Hiding the following for work on DOCS-680
235
210
### Example 4
236
211
237
212
Assume the following role filters.
@@ -245,15 +220,16 @@ Role A allows access to log data whose `_collector` tag matches “prod\*”, an
245
220
246
221
Role B prevents access to log data whose `_sourceCategory` tag does contain “shoguns”. Data with any ` _sourceCategory` tag that does not contain “shoguns” is available.
247
222
248
-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, and prepends them with an AND to your query, like this:
223
+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, and prepends them with an `AND` to your query, like this:
249
224
250
225
```sql
251
226
(_collector=prod* OR !_sourceCategory=*shoguns*) AND <your-query>
252
227
```
253
228
254
229
Role B is the least restrictive. Users with the combined role filter will be able to view any log data whose `_sourceCategory` does not contain the string “shoguns”, regardless of the value of the `_collector` tag.
230
+
-->
255
231
256
-
### Example 5
232
+
### Example 4
257
233
258
234
Assume the following role filters.
259
235
@@ -266,4 +242,8 @@ Role A allows access to all indexes whose name starts with "sumologic".
266
242
267
243
Role B, with a blank search filter (user did not enter anything as the search filter for the role), allows access to all data.
268
244
269
-
When a user with Roles A and B runs a query, Sumo combines the two filters and since Role B has a blank search filter, the more restrictive search filter, Role A, takes precedence. Users with the combined role filter will be able to view any log data in any of the indexes prefixed with "sumologic".
245
+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters and since Role B has a blank search filter, the more restrictive search filter, Role A, takes precedence. Users with the combined role filter will be able to view any log data in any of the indexes prefixed with "sumologic".
246
+
247
+
## Test role filtering
248
+
249
+
To test whether filtering works as expected, select a role and click the **Emulate log search** button. For more information, see [Test a role](/docs/manage/users-roles/roles/create-manage-roles/#test-a-roles-log-access-rights).
0 commit comments