Configure the log reducer in a Grepr pipeline
This page describes the log reducer’s settings and how to configure them to meet your requirements. When you create log reduction pipelines, Grepr adds a log reducer with default settings that control how log messages are grouped into patterns, sampled, and summarized. These settings are suitable for many log-processing workloads, but you can modify these settings to meet your requirements through the Grepr UI, the REST API, or the Grepr CLI. This page describes each setting and how to configure the setting in the UI. For the API documentation, see the LogReducer API specification. For the CLI, see The Grepr CLI.
The reducer’s settings control the following:
- Grouping decides which messages can share a pattern and how similar they must be. See Configure how messages are grouped.
- Sampling decides how many raw messages of each pattern are forwarded before the reducer starts summarizing, and whether it keeps forwarding occasional samples after that. See Configure how messages are aggregated and Configure a sampling strategy.
- Masks treat values such as timestamps, IDs, and IP addresses as interchangeable, so messages that differ only in those values share a pattern. See Group variable values with masks.
- Delimiters are the characters that separate the parts of a message that the reducer compares. See Configure delimiters used to split log messages.
- Merge strategies decide how attribute values are combined in a summary. See Configure how attributes are merged. For details on the fields included in the summarized output events, see Summary message metadata.
To modify the configuration settings in the UI, on the overview page for your pipeline, click Reducer in the left-hand navigation menu to open the Edit Reducer dialog. The dialog contains a form to configure Grouping Configuration, Aggregation Configuration, Sampling Configuration, Mask Configuration, Delimiter Configuration, and Attribute Configuration values. The following sections describe these settings.
Configure how messages are grouped
Grouping controls how incoming messages are partitioned into independent groups before pattern detection, and the level of similarity messages must meet to be considered part of the same pattern.
Group messages by a field
Messages are aggregated separately for each unique combination of values across the fields you group on, so patterns from different services, hosts, or other dimensions are never merged. Grouping on service, host, and the http.url.path attribute aggregates messages independently for each unique combination of those three values.
To group on a field, on the pipeline’s Reducer step, click Edit on the Fields card, find the field, and set its behavior to Match or split. A field with this behavior is kept out of aggregation, so messages whose values for it differ are never merged into one pattern.
Attribute paths are written with an @ prefix and dot notation for nested attributes, such as @http.url.path. Tag keys are written as the key name alone.
Use grouping to retain the values of important fields by excluding them from aggregation, such as high-cardinality identifiers like user IDs. To keep a field that is currently inside the message, parse it into an attribute or a tag with the JSON Parser or Grok Parser step earlier in the pipeline, then group on that field. See Transform JSON strings into JSON objects and Parse log messages to enrich log events with the Grok parser.
Grouping also decides how a summary can be routed, because a summary carries the tag values of the fields it was grouped on. To use grouping to send each group’s logs to a different destination, see Route logs to several vendor accounts.
Similarity threshold (%)
The similarity threshold controls how similar messages must be to belong to the same pattern. To set this threshold, enter a whole number from 20 to 100.
- A higher value requires a closer match to group messages into the same pattern. Higher values produce more distinct patterns, with fewer placeholders in each summary message, and reduce volume less aggressively.
- A lower value allows grouping messages with more variation into the same pattern. Lower values lead to greater reduction, but the resulting summary messages contain more placeholders.
Configure how messages are aggregated
The Aggregation Configuration section controls how many raw messages are forwarded before aggregation begins for a pattern and how summary messages are formatted.
Minimum number of samples
In the Minimum number of samples field, enter a whole number of two or greater. This value is the number of messages matching a pattern that the reducer forwards as raw messages in each reduction window before it begins aggregating additional matches into a summary message. The reducer step shows the reduction window. Until this number is reached, unaggregated messages are forwarded to your sinks.
Use a lower value to begin aggregation sooner and maximize volume reduction. Use a higher value when a pattern has a higher threshold for the number of duplicate messages to forward before beginning aggregation.
Add repeat count prefix to summary messages
To have the reducer prepend a prefix to each summary message that indicates the number of raw messages aggregated and the period they cover, select Add repeat count prefix to summary messages.
Clear Add repeat count prefix to summary messages if your downstream system needs to parse the summary message body without changes. For example, if summary messages use JSON formatting, the leading prefix would cause a syntax error.
Choose which fields form a pattern
To reduce logs whose useful information is in attributes, on the reducer step of your pipeline, click Edit on the Patterns card. Use Build patterns from to select the fields that determine patterns:
| Build patterns from | Behavior |
|---|---|
| Message only | Uses only the message. Empty messages pass through without reduction. This is the default. |
| Message, or attributes when empty | Uses the message when it is nonempty, otherwise the selected attributes. Summaries of empty-message events have a null message. |
| Attributes only | Ignores the message for pattern matching. Generated summaries have a null message; original samples and exceptions retain their messages. |
| Message and attributes | Uses both the message and the selected attributes. Summaries contain only the message text, and events with an empty message produce summaries with a null message. |
When attributes participate, logs share a pattern only when their selected attributes have the same keys, the same nesting, and the same kind of value: null, a single value, a list, or an object. Key order does not matter. For example, {"error": null} and {"error": "timeout"} form separate patterns. When the message is read from an attribute that holds a string, that attribute does not participate either: it is used as the message or, with Attributes only, ignored along with the message. An attribute holding anything else, such as an object body, provides no message and participates like any other attribute.
With the default, Message only, attributes are not used. The attribute settings below appear when you set Build patterns from to an option that uses attributes.
Use Attribute values to choose how selected attributes affect similarity scoring:
- Compare values: Logs whose attribute values differ too much form separate patterns. A mask applies to a value only when it matches the entire value.
- Ignore values: Attribute values don’t affect matching, apart from the kind of value described above. Message similarity and grouping fields still apply.
Include or exclude attribute subtrees
Use Include attributes and Exclude attributes to select the attribute structure and values that participate in pattern matching. Enter each attribute path the same way as in the Fields dialog: @ followed by the path in dot notation, or a JSON array for a key that contains a dot. For example, @request.headers selects the nested request.headers subtree, while @["request.headers"] selects a top-level key containing a literal dot.
Leave the include field empty to include all attributes. Exclusions take precedence over includes. Prefixes select complete subtrees and address keys inside array elements without an array index. Excluded fields don’t affect which pattern a log matches.
These settings affect pattern matching. They do not remove attributes from events or change their configured merge strategies. An excluded attribute can still be an explicit grouping value. If neither message text nor selected attributes remain, the event passes through.
For example, this reducer configuration uses request keys for matching while requiring the excluded tenant value to match exactly:
{
"type": "log-reducer",
"tokenizationInput": "ATTRIBUTES_ONLY",
"attributeTokenization": "KEYS_ONLY",
"includedAttributePrefixes": [["request"]],
"excludedAttributePrefixes": [["request", "tenant_id"], ["request", "trace_id"]],
"partitionByAttributePaths": [["request", "tenant_id"]]
}The tokenizationInput setting defaults to MESSAGE_ONLY, which is Message only, so attributes are not used. When attributes are used, attributeTokenization defaults to KEYS_AND_VALUES, which is Compare values, and empty attribute lists select every attribute.
Configure a sampling strategy
The Sampling Configuration section controls whether additional raw messages are forwarded for a pattern after the minimum number of samples is reached. To configure the sampling strategy for a reducer, in the Sampling strategy menu, select one of the following options:
No Additional Sampling
Grepr passes through a configurable number of sample messages for each pattern before beginning aggregation. After the minimum number of samples is reached for a specific pattern, Grepr stops sending raw messages for that pattern for the rest of the reduction window and summarizes them. This ensures that a minimum number of raw messages always pass through unmodified. Low-frequency messages that usually contain important troubleshooting information pass through unmodified.
While this default behavior maximizes reduction, the count of messages seen at the vendor no longer tracks the number of original raw messages. Features in external log aggregators that depend on message counts by pattern, such as Datadog’s “top patterns” capability, might not work as expected. To address this, select the following logarithmic sampling option.
Window-Based Logarithmic
With logarithmic sampling, Grepr keeps forwarding occasional raw samples of a pattern after the minimum number of samples is reached, and forwards proportionally fewer as the pattern’s volume grows. An unexpectedly large increase in messages matching a pattern still appears as an increase in message count at the vendor, at a much smaller magnitude.
When you select this option, enter a whole number of two or greater in the Logarithm Base field. A larger base forwards fewer additional samples as volume grows, and a smaller base forwards more.
Group variable values with masks
The Mask Configuration section defines the regular expression masks that identify variable parts of a log message, such as timestamps, IDs, or IP addresses. Messages that differ only in masked values are grouped into the same pattern.
The reducer ships with the following default masks. Each appears as a row in the Mask Configuration section and can be enabled, disabled, edited, or reset to its original pattern:
| Mask | Default state | Description |
|---|---|---|
timestamp | Enabled | Matches many timestamp formats, such as 2024-04-26T15:30:45.123Z, 26/04/2024 15:30:45, or 15:30:45. |
ipport | Enabled | Matches IPv4 addresses and optional ports, such as 192.168.0.1 or 192.168.0.1:8080. |
number | Enabled | Matches integers and decimal numbers up to 100 digits. |
uuid | Enabled | Matches UUIDs, such as 123e4567-e89b-12d3-a456-426614174000. |
anydigit | Enabled | Matches a word of letters and digits that has both, such as abc123, u_42x, or v2. Words of digits alone are left to number. It has the lowest priority: where another enabled mask, default or custom, matches the same text, that mask wins. Where another mask matches only part of the word, anydigit can win, as the leftmost match is taken first: with a custom \d{6} mask, ORD123456 becomes <anydigit>. |
awsarn | Disabled | Matches AWS ARNs. |
awstoken | Disabled | Matches AWS session tokens. |
For each mask row, you can:
- Select or clear the checkbox on the left to enable or disable the mask. Only enabled masks are applied to incoming messages.
- Click Edit to display the regular expression for the mask and modify the pattern. The pattern field cannot be empty.
- For default masks, click the restore icon to reset the pattern to its original value.
- For custom masks, click the delete icon to remove the mask.
Add custom masks for other formats
To ensure the correct grouping of fields with formats that aren’t handled by the default masks, you can create custom masks. For example, you might have a field with values that include delimiter characters, and you need the reducer to treat each value as a single unit.
When you add a custom mask, you must enter a name for the mask that:
- Contains only lowercase alphabetic characters. Spaces, digits, and symbols are not allowed.
- Is no more than 50 characters long.
- Is unique across all masks in this reducer.
Enter the mask in the Regular Expression Pattern text box. A custom mask pattern supports the following common regular expression constructs:
- Literal characters and character classes, such as
[a-z], along with predefined classes such as\d,\w, and\s. - Quantifiers, such as
*,+,?, and{n,m}. - Alternation with
|and grouping with(and). - Anchors and word boundaries, such as
^,$, and\b.
Custom mask patterns do not support lookahead or lookbehind assertions or backreferences. A pattern that uses one of these constructs passes the validation in the form but prevents the reducer from processing messages. To confirm that a custom mask matches the values you expect, test the pattern against sample messages.
Configure delimiters used to split log messages
The Delimiter Configuration section defines the characters that separate the parts of a log message that the reducer compares. Characters that are not in the delimiter list are treated as part of a word.
The default delimiter set contains common punctuation and whitespace characters: :, #, [, ], (, ), {, }, |, ,, ;, ", ', &, =, ?, !, +, *, /, <, >, %, ^, ~, `, space, \t, \n, and \r.
The default set intentionally omits @ and . so that email addresses and dotted identifiers, such as fully qualified class names, are not split apart.
To modify the delimiter list:
- To remove a delimiter, hover over its chip in the delimiter list and click the delete icon that appears.
- To add a delimiter, enter the character in the Add delimiter field and click Add or press Enter. For control characters, enter the escape sequence:
\tfor tab,\nfor newline,\rfor carriage return,\bfor backspace,\ffor form feed,\vfor vertical tab, or\0for null. Duplicate delimiters are rejected. - To restore the default delimiter set, click Reset to Defaults.
Configure how attributes are merged
The log reducer groups events using the configured pattern inputs. Attribute values can differ within a group, so the reducer provides multiple strategies to merge them. These merge strategies also apply to attributes excluded from pattern matching.
To control how the reducer combines attributes, you use the Attribute Configuration section to specify merge strategies for individual attribute paths and configure a default strategy that applies to any attribute path without an explicit configuration.
The reducer supports the following merge strategy types:
| Strategy | Behavior |
|---|---|
| Exact Match | If all aggregated messages have the same value for the attribute, the summary preserves that value. If they differ, the summary stores a wildcard, *. |
| Sample | Collects up to a configured Sample Limit of values from the aggregated messages. When the limit is reached, additional values are dropped. |
| Preserve All | Collects every distinct or repeated value from the aggregated messages, up to a configured Preserve Limit. When the incoming data exceeds the limit, the reducer emits the current summary and starts a new one, rather than dropping values. |
| Sum | Sums numeric values across aggregated messages and stores the result as a scalar number. Non-numeric values are ignored. Collections of numbers are summed element by element. |
| Min | Keeps the minimum numeric value across aggregated messages. Non-numeric values are ignored. |
| Max | Keeps the maximum numeric value across aggregated messages. Non-numeric values are ignored. |
| Average | Computes the arithmetic mean of numeric values across aggregated messages. Non-numeric values are ignored. |
To see examples and learn more about the merge strategies, see Merge strategy examples.
Configure merge strategies
To add a merge strategy, in the Attribute merging strategies section, click the plus (+) icon. Select a strategy from the Strategy menu and enter the target attribute path. If any part of the target path uses dot notation, enter the target path using dot notation, such as http.response.bytes, or a JSON array, such as ["http", "response", "bytes"]. Each entry must have a non-empty path, and each path must be unique within the list.
When you select Sample or Preserve All, you can configure the following settings:
- Sample Limit or Preserve Limit: A whole number that’s one or greater. These values cap the size of the collected values. Sample defaults to 10 and Preserve All defaults to 1000.
- Keep unique values only: When selected, the reducer stores the collected values as a set and discards duplicates. When cleared, the reducer stores the values as a list and preserves duplicates.
When you configure more than one strategy for the same attribute path, the reducer writes a separate attribute in the summary for each strategy, using a suffix such as _sum, _avg, or _min. The first strategy in the list also writes to the base attribute name. For example, configuring Sum and then Average for bytes_sent produces bytes_sent_sum, which is also written to bytes_sent, and bytes_sent_avg. To change the order in which strategies are applied, drag them in the list.
Adding multiple strategies, whether to a specific path or the default, adds additional attributes to the summary. Use multiple strategies only when your analytics or dashboards need more than one aggregated form of the same attribute.
Each strategy type can be used only once per attribute path.
Configure the default strategy
The Default Strategy section defines the strategies that apply to every attribute path that is not configured under Attribute merging strategies. You must configure at least one default strategy. Exact Match is the default.
As with path-specific strategies, you can add multiple default strategies. When you add multiple default strategies, each strategy produces a suffixed attribute in the summary, and the first strategy also writes to the base attribute name.
Send new-pattern signals to AI agents
You can have the pipeline report each new log pattern to your Grepr AI agents, so an agent investigates behavior that is new in your systems without you writing an alert for it first.
To turn this on, on the reducer step of your pipeline, open the Advanced settings and select Emit new-pattern signals to AI agents.
Turning it on emits nothing by itself. A signal reaches an agent only when that agent is subscribed to the pipeline, and Grepr refuses a subscription to a pipeline that has this setting off. So turn it on first, then subscribe the agent.
Each pattern signals each subscribed agent once rather than on every occurrence, so a pattern that keeps matching does not keep starting investigations. To learn how signals reach an agent and how to bound the volume, see Subscribe an agent to signal sources.