FilterPattern

class aws_cdk.aws_logs.FilterPattern

Bases: object

A collection of static methods to generate appropriate ILogPatterns.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Return type

None

Static Methods

classmethod all(*patterns)

A JSON log pattern that matches if all given JSON log patterns match.

Parameters

patterns (JsonPattern) –

Return type

JsonPattern

classmethod all_events()

A log pattern that matches all events.

Return type

IFilterPattern

classmethod all_terms(*terms)

A log pattern that matches if all the strings given appear in the event.

Parameters

terms (str) – The words to search for. All terms must match.

Return type

IFilterPattern

classmethod any(*patterns)

A JSON log pattern that matches if any of the given JSON log patterns match.

Parameters

patterns (JsonPattern) –

Return type

JsonPattern

classmethod any_term(*terms)

A log pattern that matches if any of the strings given appear in the event.

Parameters

terms (str) – The words to search for. Any terms must match.

Return type

IFilterPattern

classmethod any_term_group(*term_groups)

A log pattern that matches if any of the given term groups matches the event.

A term group matches an event if all the terms in it appear in the event string.

Parameters

term_groups (List[str]) – A list of term groups to search for. Any one of the clauses must match.

Return type

IFilterPattern

classmethod boolean_value(json_field, value)

A JSON log pattern that matches if the field exists and equals the boolean value.

Parameters
  • json_field (str) – Field inside JSON. Example: “$.myField”

  • value (bool) – The value to match.

Return type

JsonPattern

classmethod exists(json_field)

A JSON log patter that matches if the field exists.

This is a readable convenience wrapper over ‘field = *

Parameters

json_field (str) – Field inside JSON. Example: “$.myField”

Return type

JsonPattern

classmethod is_null(json_field)

A JSON log pattern that matches if the field exists and has the special value ‘null’.

Parameters

json_field (str) – Field inside JSON. Example: “$.myField”

Return type

JsonPattern

classmethod literal(log_pattern_string)

Use the given string as log pattern.

See https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html for information on writing log patterns.

Parameters

log_pattern_string (str) – The pattern string to use.

Return type

IFilterPattern

classmethod not_exists(json_field)

A JSON log pattern that matches if the field does not exist.

Parameters

json_field (str) – Field inside JSON. Example: “$.myField”

Return type

JsonPattern

classmethod number_value(json_field, comparison, value)

A JSON log pattern that compares numerical values.

This pattern only matches if the event is a JSON event, and the indicated field inside compares with the value in the indicated way.

Use ‘$’ to indicate the root of the JSON structure. The comparison operator can only compare equality or inequality. The ‘*’ wildcard may appear in the value may at the start or at the end.

For more information, see:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html

Parameters
  • json_field (str) – Field inside JSON. Example: “$.myField”

  • comparison (str) – Comparison to carry out. One of =, !=, <, <=, >, >=.

  • value (Union[int, float]) – The numerical value to compare to.

Return type

JsonPattern

classmethod space_delimited(*columns)

A space delimited log pattern matcher.

The log event is divided into space-delimited columns (optionally enclosed by “” or [] to capture spaces into column values), and names are given to each column.

‘…’ may be specified once to match any number of columns.

Afterwards, conditions may be added to individual columns.

Parameters

columns (str) – The columns in the space-delimited log stream.

Return type

SpaceDelimitedTextPattern

classmethod string_value(json_field, comparison, value)

A JSON log pattern that compares string values.

This pattern only matches if the event is a JSON event, and the indicated field inside compares with the string value.

Use ‘$’ to indicate the root of the JSON structure. The comparison operator can only compare equality or inequality. The ‘*’ wildcard may appear in the value may at the start or at the end.

For more information, see:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html

Parameters
  • json_field (str) – Field inside JSON. Example: “$.myField”

  • comparison (str) – Comparison to carry out. Either = or !=.

  • value (str) – The string value to compare to. May use ‘*’ as wildcard at start or end of string.

Return type

JsonPattern