Skip to content

Commit 89f39cc

Browse files
authored
Merge pull request #376 from Pranjal-Gupta2/docs/in_tail_with_throttle
1.0: in_tail_with_throttle: Add `<group>` directive description
2 parents ed379b4 + c0a9c1e commit 89f39cc

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

input/tail.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,80 @@ The `@log_level` option allows the user to set different levels of logging for e
402402

403403
Refer to the [Logging](../deployment/logging.md) for more details.
404404

405+
406+
### `<group>` Section
407+
408+
The `in_tail` plugin can assign each log file to a group, based on user defined rules. The `limit` parameter controls the total number of lines collected for a group within a `rate_period` time interval.
409+
410+
Example:
411+
412+
```text
413+
# group rules -- 1
414+
<group>
415+
rate_period 5s
416+
417+
<rule>
418+
match {
419+
namespace: /shopping/,
420+
podname: /frontend/,
421+
}
422+
limit 1000
423+
</rule>
424+
</group>
425+
426+
# group rules -- 2
427+
<group>
428+
<rule>
429+
match {
430+
directoy: /payment/
431+
}
432+
limit 2000
433+
</rule>
434+
</group>
435+
```
436+
437+
#### `pattern`
438+
439+
| type | default | version |
440+
| :--- | :--- | :--- |
441+
| regexp | `/^\/var\/log\/containers\/(?<podname>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\/[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace>[^_]+)_(?<container>.+)-(?<docker_id>[a-z0-9]{64})\.log$/`| 1.15 |
442+
443+
Specifies the regular expression for extracting metadata (namespace, podname) from log file path. Default value of the pattern regexp extracts information about `namespace`, `podname`, `docker_id`, `container` of the log (K8s specific).
444+
445+
You can also add custom named captures in `pattern` for custom grouping of log files. For example,
446+
```text
447+
pattern /^\/home\/logs\/(?<file>.+)\.log$/
448+
```
449+
In this example, filename will be extracted and used to form groups.
450+
451+
#### `rate_period`
452+
453+
| type | default | version |
454+
| :--- | :--- | :--- |
455+
| time | 60 \(seconds\) | 1.15 |
456+
457+
Time period in which the group line limit is applied. `in_tail` resets the counter after every `rate_period` interval.
458+
459+
#### `<rule>` Section \(required\)
460+
461+
Grouping rules for log files.
462+
463+
##### match
464+
465+
| type | default | version |
466+
| :--- | :--- | :--- |
467+
| hash | {"namespace": /./, "podname": /./} | 1.15 |
468+
469+
`match` parameter is used to check if a file belongs to a particular group based on hash keys (named captures from `pattern`) and hash values (regexp)
470+
471+
##### limit
472+
473+
| type | default | version |
474+
| :--- | :--- | :--- |
475+
| integer | -1 | 1.15 |
476+
477+
Maximum number of lines allowed from a group in `rate_period` time interval. The default value of `-1` doesn't throttle log files of that group.
478+
405479
## Learn More
406480

407481
* [Input Plugin Overview](./)
@@ -469,3 +543,25 @@ path C:\\path\\to\\*\\foo.log
469543

470544
If this article is incorrect or outdated, or omits critical information, please [let us know](https://github.com/fluent/fluentd-docs-gitbook/issues?state=open). [Fluentd](http://www.fluentd.org/) is an open-source project under [Cloud Native Computing Foundation \(CNCF\)](https://cncf.io/). All components are available under the Apache 2 License.
471545

546+
### What happens when a file can be assigned to more than one group?
547+
548+
Example,
549+
550+
```text
551+
<rule> ## Rule1
552+
match {
553+
namespace: /monitoring/
554+
}
555+
limit 100
556+
</rule>
557+
558+
<rule> ## Rule2
559+
match {
560+
namespace: /monitoring/,
561+
podname: /logger/,
562+
}
563+
limit 2000
564+
</rule>
565+
```
566+
567+
In this case, rules with more constraints, i.e., greater number of `match` hash keys will be given a higher priority. So a file will be assigned to `Rule2` if it can be assigned to both `Rule1` and `Rule2`.

0 commit comments

Comments
 (0)