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-23Lines changed: 37 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ 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
11
@@ -25,23 +25,25 @@ When a user with this filter enters a query like:
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
36
37
```
37
38
!_sourceCategory=JobX*
38
39
```
39
40
40
41
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.)
42
+
-->
41
43
42
44
The examples above are simple: they involve a single role, and hence a single role filter.
43
45
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).
46
+
Typically however, a Sumo Logic user will have multiple roles. If a user has multiple roles, Sumo Logic`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
47
46
48
## Search filter basics
47
49
@@ -69,33 +71,33 @@ You can use metadata fields in a role search filter. The following search filter
69
71
_collector=HR_Tools
70
72
```
71
73
72
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
74
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
73
75
74
76
```sql
75
77
_collector=HR_Tools AND<user-query>
76
78
```
77
79
78
80
### Using AND and OR in a search filter
79
81
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:
82
+
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
83
82
84
```sql
83
85
_sourceCategory=stock OR _sourceCategory=insurance
84
86
```
85
87
86
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
88
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
87
89
88
90
```sql
89
91
(_sourceCategory=stock OR _sourceCategory=insurance) AND<user-query>
90
92
```
91
93
92
-
This role filter below uses AND to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
94
+
This role filter below uses `AND` to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
93
95
94
96
```sql
95
97
_collector=HR_Tools AND _sourceCategory=insurance
96
98
```
97
99
98
-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
100
+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
99
101
100
102
```sql
101
103
(_collector=HR_Tools AND _sourceCategory=insurance) AND<user-query>
@@ -109,7 +111,7 @@ You can include a string you want to search for in a role search filter. This ro
109
111
_collector=HR_Tools AND enrollment
110
112
```
111
113
112
-
When a user with that role filter runs a query, Sumo runs it like this:
114
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
113
115
114
116
```sql
115
117
(_collector=HR_Tools AND enrollment) AND<user-query>
@@ -123,7 +125,7 @@ You can use an asterisk (\*) as a wildcard in a role search filter. This role fi
123
125
_collector=HR*
124
126
```
125
127
126
-
When a user with that role filter runs a query, Sumo runs it like this:
128
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
127
129
128
130
```sql
129
131
_collector=HR*AND<user-query>
@@ -135,7 +137,7 @@ This role filter grants access to logs that contain the string “violation” f
135
137
_collector=HR*AND violation
136
138
```
137
139
138
-
When a user with that role filter runs a query, Sumo runs it like this:
140
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
139
141
140
142
```sql
141
143
(_collector=HR*AND violation) AND<user-query>
@@ -155,15 +157,21 @@ denies access to log data whose:
155
157
*`_sourceName` contains “finance”
156
158
*`_sourceCategory` contains “secret”
157
159
158
-
When a user with that role filter runs a query, Sumo runs it like this:
160
+
When a user with that role filter runs a query, Sumo Logic runs it like this:
Although we provide this an example to show that it's possible, we do not recommend filtering to deny access. That's because if multiple roles are applied to a user, a situation can arise where one role denies access to a certain area, but another role allows access to that same area. Therefore, if possible, always apply filtering that allows access rather than denies access. Then roles can be used in an additive way to build access for users.
168
+
:::
169
+
164
170
## Multiple role filters and filter precedence
165
171
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.
172
+
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.
173
+
174
+
<RoleStacking/>
167
175
168
176
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
177
@@ -180,7 +188,7 @@ Role A allows access to log data whose `_source` tag is “GCP Audit” and `_co
180
188
181
189
Role B Allows access to log data whose `_sourceCategory` tag begins with “Vx”.
182
190
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:
191
+
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
192
185
193
```sql
186
194
((_source="GCP Audit"AND _collector="GCP") OR _sourceCategory="Vx*")
@@ -196,19 +204,19 @@ Assume the following role filters.
196
204
| Role | Filter |
197
205
|:----------|:-------------------|
198
206
| Role A |`_collector=fee*`|
199
-
| Role B |`!_collector=fi*`|
207
+
| Role B |`_collector=f*`|
200
208
201
209
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
210
203
-
Role B Allows access to any log data whose `_collector` tag does not match “fi”.
211
+
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
212
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:
213
+
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
214
207
215
```sql
208
-
(_collector=fee OR!_collector=fi) AND<your-query>
216
+
(_collector=fee OR _collector=f) AND<your-query>
209
217
```
210
218
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.
219
+
**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
220
213
221
### Example 3
214
222
@@ -224,14 +232,15 @@ Role A allows access only to log data whose `_sourceCategory` is “analytics-la
224
232
225
233
Role B Allows access to log data whose `_sourceCategory` begins with “analytics”.
226
234
227
-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, like this:
235
+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, like this:
228
236
229
237
```sql
230
238
(_sourceCategory=analytics-lab OR _sourceCategory=analytics*) AND<your-query>
231
239
```
232
240
233
241
**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
242
243
+
<!-- Hiding the following for work on DOCS-680
235
244
### Example 4
236
245
237
246
Assume the following role filters.
@@ -245,15 +254,16 @@ Role A allows access to log data whose `_collector` tag matches “prod\*”, an
245
254
246
255
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
256
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:
257
+
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
258
250
259
```sql
251
260
(_collector=prod* OR !_sourceCategory=*shoguns*) AND <your-query>
252
261
```
253
262
254
263
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.
264
+
-->
255
265
256
-
### Example 5
266
+
### Example 4
257
267
258
268
Assume the following role filters.
259
269
@@ -266,4 +276,8 @@ Role A allows access to all indexes whose name starts with "sumologic".
266
276
267
277
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
278
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".
279
+
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".
280
+
281
+
## Test role filtering
282
+
283
+
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