matchfilter()
The matchfilter() function applies the condition expression defined in a user-defined filter to the current record and returns a boolean result.
Syntax
matchfilter(STR_GUID)
matchfilter(STR_UDF_NAME)
matchfilter(STR_UDF_NAME)
Parameters
STR_GUID- The GUID of the user-defined filter. Must be a valid user-defined filter identifier. If a non-existent GUID is specified, an error occurs at query parse time.
STR_UDF_NAME- The name of the user-defined filter. If a non-existent name is specified, an error occurs at query parse time.
Description
The matchfilter() function applies and evaluates the condition expression stored in a user-defined filter against the current record. If the evaluation result is of boolean type, that value is returned; if it is not boolean, true is returned when the result is non-null, and false is returned when the result is null.
User-defined filters are managed in the Sonar web console under Policies > User-Defined Filters.
Error codes
N/A
Usage examples
-
Apply a user-defined filter by GUID
json "{'src_ip': '192.0.2.1'}" | eval result = matchfilter("68e2a243-5e24-4711-b592-32a48d1fc5e5") | # result: false -
Apply a user-defined filter by filter name
json "{'src_ip': '192.0.2.1', 'dst_port': 443}" | eval result = matchfilter("내부망 출발지 필터") | # result: false -
The condition expression evaluates to
nulljson "{'src_ip': null}" | eval result = matchfilter("68e2a243-5e24-4711-b592-32a48d1fc5e5") | # result: false
Compatibility
matchfilter() has been available since Sonar 4.0.2305.0.