matchbehavior
Matches input records against a behavior profile using the key fields defined in the profile, and appends the value fields from matched behavior profile records to the output records.
Command properties
| Property | Description |
|---|---|
| Command type | Transforming |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
In the syntax above, name is available starting with 4.0.2609.0.
Options
guid=STR- Behavior profile GUID. In the 5.0 series (through 5.0.2605.2), this is the only way to specify the target. In the 4.0 series (4.0.2609.0 and later), this option cannot be used together with
name, and you must specify eitherguidorname. name=STR- Behavior profile name (cannot be used together with
guid). You must specify either theguidornameoption. This option is available starting with 4.0.2609.0. invert=BOOL- Inverts the match result. When set to
t, outputs records that are not included in the behavior profile. (Default:f) verify=BOOL- Whether to validate the behavior profile object. When set to
f, skips validation of the behavior profile at parse time. (Default:t)
Output fields
On match success (invert=f):
| Field | Type | Description |
|---|---|---|
behavior_guid | string | GUID of the matched behavior profile |
behavior_invert | boolean | Whether inversion is enabled |
| Behavior profile value fields | - | All value fields from the matched behavior profile record are appended to the output record. |
On match failure (invert=t):
| Field | Type | Description |
|---|---|---|
behavior_guid | string | Behavior profile GUID |
behavior_invert | boolean | Whether inversion is enabled |
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| 300030 | Specify 'guid' option in the matchbehavior command. | The guid option is not specified. The error code differs by series — the 5.0 series (through 5.0.2605.2) reports 300030; the 4.0 series (4.0.2609.0 and later) reports 300043 instead. |
| 300031 | The GUID in the matchbehavior command is invalid format. | The guid option value is not a valid GUID. |
| 300032 | Behavior profile not found. | No behavior profile exists for the specified GUID (validated only when verify=t). |
| 300033 | Cannot load behavior profile. | An error occurred while reading the behavior profile data. |
| 300043 | Specify 'guid' or 'name' option in the matchbehavior command. | Neither the guid nor the name option is specified. Available starting with 4.0.2609.0, which has the name option. |
| 300044 | Behavior profile not found by name. | No behavior profile exists with the name specified in the name option. Available starting with 4.0.2609.0, which has the name option. |
| 300045 | Duplicate behavior profile name. | More than one behavior profile exists with the name specified in the name option. Available starting with 4.0.2609.0, which has the name option. |
| 300047 | Specify only one of 'guid' or 'name' option in the matchbehavior command. | Both the guid and name options are specified. Available starting with 4.0.2609.0, which has the name option. |
Runtime errors
None
Description
The matchbehavior command compares input records against behavior profile data using the key field values defined in the behavior profile. If the key field value of an input record exists in the behavior profile, all value fields from the matched behavior profile record are merged into the input record and output.
Use the guid option to specify which behavior profile to match against. In the 4.0 series (4.0.2609.0 and later), you can also use the name option; the command looks up the profile by that name to resolve its GUID, and specifying both guid and name, or omitting both, causes an error, as does specifying a name that does not exist or that matches more than one profile.
When invert=t is specified, only records not found in the behavior profile are output. In this case, the value fields of the behavior profile are not appended.
When verify=f is specified, the behavior profile is not validated at parse time. The profile is loaded at execution time, which is useful when the profile is still being built.
Examples
-
Match records against a behavior profile
json "[{'src_ip': '192.0.2.1'}, {'src_ip': '198.51.100.5'}]" | matchbehavior guid=550e8400-e29b-41d4-a716-446655440000Matches input records against the behavior profile with the specified GUID using its key fields, and appends the profile's value fields to matched records.
-
Filter out matched records
json "[{'src_ip': '192.0.2.1'}, {'src_ip': '198.51.100.5'}]" | matchbehavior guid=550e8400-e29b-41d4-a716-446655440000 invert=tOutputs only records not included in the behavior profile.
-
Match without validation
json "[{'src_ip': '192.0.2.1'}]" | matchbehavior guid=550e8400-e29b-41d4-a716-446655440000 verify=fSkips validation of the behavior profile's existence and performs matching. Useful when the profile is still being built.
-
Specifying a behavior profile by name (4.0 series, 4.0.2609.0 and later)
table limit=1000 WEB_APACHE_SAMPLE | matchbehavior name=web_attacker_profileMatches using a behavior profile specified by name instead of GUID.
Change history
| Target | Introduced in |
|---|---|
The matchbehavior command | Before Sonar 4.0 |
The name option | 4.0.2609.0 |