Synopsis: |
rate-limit(template($HOST) rate(5000)) |
Description: Limits messages rate based on arbitrary keys in each message. The key will be resolved using the template() option. Each resolution will be allowed to have the number of messages each second, set by the rate() option. For example if template($HOST) and rate(5000) are set, and there are 2 hosts sending messages to syslog-ng OSE, a total of 10000 messages will be allowed by the rate-limit() filter, 5000 from the first and 5000 from the second host. If template() was not set instead, then 5000 messages would be allowed each second, regardless of their content.
NOTE: In syslog-ng OSE version 3.35 the rate-limit() filter was called throttle(). In syslog-ng OSE version 3.36 it got renamed to rate-limit(), but throttle() is still available for backward compatibility.
NOTE: Like every other filter, messages unmatched (outside of the rate limit) by the rate-limit() filter are dropped by default. Also, as every filter can be used in channels or if conditions, the messages unmatched can be caught and handled, like sent to a different destination, and so on.
Example: Using the rate-limit() filter
The following example depicts the scenario described in the description part of this section.
filter f_rate_limit {
rate-limit(
template("$HOST")
rate(5000)
);
};
The rate-limit() filter has the following options.
rate()
Type: |
number |
Default: |
N/A |
Mandatory: |
yes |
Description: The number of messages for each unique macro resolution, that will be let through (matched) by the filter each second.
template()
Type: |
template |
Default: |
empty string |
Description: The resolved template, that will be used to create unique rate-limit token buckets.
Description: Select messages of a source statement. This filter can be used in embedded log statements if the parent statement contains multiple source groups — only messages originating from the selected source group are sent to the destination of the embedded log statement.
Description: Select messages labeled with the specified tag. Every message automatically has the tag of its source in .source.<id_of_the_source_statement> format. This option is available only in syslog-ng 3.1 and later.
Example: Adding tags and filtering messages with tags
source s_tcp {
network(ip(192.168.1.1) port(1514) tags("tcp", "router"));
};
Use the tags() option of the filters to select only specific messages:
filter f_tcp {
tags(".source.s_tcp");
};
filter f_router {
tags("router");
};
NOTE: The syslog-ng OSE application automatically adds the class of the message as a tag using the .classifier.<message-class> format. For example, messages classified as "system" receive the .classifier.system tag. Use the tags() filter function to select messages of a specific class.
filter f_tag_filter {tags(".classifier.system");};