Skip to content

Commit 1e20ea0

Browse files
committed
pipeline: processor: sampling: document missing Regex support in string attr
Signed-off-by: Eduardo Silva <[email protected]>
1 parent ca3118d commit 1e20ea0

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

pipeline/processors/sampling.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ pipeline:
204204

205205
With this tail-based sampling configuration, a sample set of ingested traces will select only the spans with status codes marked as `ERROR` to the standard output.
206206

207+
207208
### Condition: string_attribute
208209

209210
This conditional allows traces to be sampled based on specific span or resource attributes. Users can define key-value filters (e.g., http.method=POST) to selectively capture relevant traces.
@@ -212,7 +213,13 @@ This conditional allows traces to be sampled based on specific span or resource
212213
| :----------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----------: |
213214
| `key` | Specifies the span or resource attribute to match (e.g., "service.name"). | |
214215
| `values` | Defines an array of accepted values for the attribute. A trace is sampled if any span contains a matching key-value pair: `["payment-processing"]` | |
215-
| `match_type` | Defines how attributes are compared: `strict` ensures exact value matching, while `exists` checks if the attribute is present regardless of its value (note that string type is enforced) | `strict` |
216+
| `match_type` | Defines how attributes are compared: `strict` ensures exact value matching, `exists` checks if the attribute is present regardless of its value, and `regex` enables regular expression pattern matching | `strict` |
217+
218+
#### Match Types
219+
220+
- **`strict`**: Exact value matching (case-sensitive)
221+
- **`exists`**: Checks if the attribute key is present, regardless of its value
222+
- **`regex`**: Matches values using regular expression patterns
216223

217224
**fluent-bit.yaml**
218225

@@ -235,20 +242,40 @@ pipeline:
235242
sampling_settings:
236243
decision_wait: 2s
237244
conditions:
245+
# Exact matching
238246
- type: string_attribute
239247
match_type: strict
240248
key: "http.method"
241249
values: ["GET"]
250+
251+
# Check if attribute exists
242252
- type: string_attribute
243253
match_type: exists
244254
key: "service.name"
245255
256+
# Regex pattern matching
257+
- type: string_attribute
258+
match_type: regex
259+
key: "http.url"
260+
values: ["^https://api\\..*", ".*\\/health$"]
261+
262+
# Multiple regex patterns for error conditions
263+
- type: string_attribute
264+
match_type: regex
265+
key: "error.message"
266+
values: ["timeout.*", "connection.*failed", ".*rate.?limit.*"]
267+
246268
outputs:
247269
- name: stdout
248270
match: "*"
249271
```
250272

251-
This tail-based sampling configuration waits 2 seconds before making a decision. It samples traces based on string matching key value pairs. Traces are sampled if the key `http.method` is set to `GET` or if spans or resources have a key `service.name`.
273+
This tail-based sampling configuration waits 2 seconds before making a decision. It samples traces based on string matching key value pairs:
274+
275+
- Traces with `http.method` exactly equal to `GET`
276+
- Traces that have a `service.name` attribute (any value)
277+
- Traces with `http.url` starting with `https://api.` or ending with `/health`
278+
- Traces with `error.message` containing timeout, connection failed, or rate limit patterns
252279

253280
### Condition: numeric_attribute
254281

0 commit comments

Comments
 (0)