ILogGroup

class aws_cdk.aws_logs.ILogGroup(*args, **kwargs)

Bases: aws_cdk.core.IResource, typing_extensions.Protocol

__init__(*args, **kwargs)

Methods

add_metric_filter(id, *, filter_pattern, metric_name, metric_namespace, default_value=None, metric_value=None)

Create a new Metric Filter on this Log Group.

Parameters
  • id (str) – Unique identifier for the construct in its parent.

  • props – Properties for creating the MetricFilter.

  • filter_pattern (IFilterPattern) – Pattern to search for log events.

  • metric_name (str) – The name of the metric to emit.

  • metric_namespace (str) – The namespace of the metric to emit.

  • default_value (Union[int, float, None]) – The value to emit if the pattern does not match a particular event. Default: No metric emitted.

  • metric_value (Optional[str]) – The value to emit for the metric. Can either be a literal number (typically “1”), or the name of a field in the structure to take the value from the matched event. If you are using a field value, the field value must have been matched using the pattern. If you want to specify a field from a matched JSON structure, use ‘$.fieldName’, and make sure the field is in the pattern (if only as ‘$.fieldName = *’). If you want to specify a field from a matched space-delimited structure, use ‘$fieldName’. Default: “1”

Return type

MetricFilter

add_stream(id, *, log_stream_name=None)

Create a new Log Stream for this Log Group.

Parameters
  • id (str) – Unique identifier for the construct in its parent.

  • props – Properties for creating the LogStream.

  • log_stream_name (Optional[str]) – The name of the log stream to create. The name must be unique within the log group. Default: Automatically generated

Return type

LogStream

add_subscription_filter(id, *, destination, filter_pattern)

Create a new Subscription Filter on this Log Group.

Parameters
  • id (str) – Unique identifier for the construct in its parent.

  • props – Properties for creating the SubscriptionFilter.

  • destination (ILogSubscriptionDestination) – The destination to send the filtered events to. For example, a Kinesis stream or a Lambda function.

  • filter_pattern (IFilterPattern) – Log events matching this pattern will be sent to the destination.

Return type

SubscriptionFilter

extract_metric(json_field, metric_namespace, metric_name)

Extract a metric from structured log events in the LogGroup.

Creates a MetricFilter on this LogGroup that will extract the value of the indicated JSON field in all records where it occurs.

The metric will be available in CloudWatch Metrics under the indicated namespace and name.

Parameters
  • json_field (str) – JSON field to extract (example: ‘$.myfield’).

  • metric_namespace (str) – Namespace to emit the metric under.

  • metric_name (str) – Name to emit the metric under.

return :rtype: Metric :return: A Metric object representing the extracted metric

grant(grantee, *actions)

Give the indicated permissions on this log group and all streams.

Parameters
Return type

Grant

grant_write(grantee)

Give permissions to write to create and write to streams in this log group.

Parameters

grantee (IGrantable) –

Return type

Grant

Attributes

log_group_arn

The ARN of this log group.

attribute: :attribute:: true

Return type

str

log_group_name

The name of this log group.

attribute: :attribute:: true

Return type

str

node

The construct node in the tree.

Return type

ConstructNode

stack

The stack in which this resource is defined.

Return type

Stack