aws-cdk-lib.aws_logs.ILogGroup

interface ILogGroup

LanguageType name
.NETAmazon.CDK.AWS.Logs.ILogGroup
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslogs#ILogGroup
Javasoftware.amazon.awscdk.services.logs.ILogGroup
Pythonaws_cdk.aws_logs.ILogGroup
TypeScript (source)aws-cdk-lib » aws_logs » ILogGroup

Implemented by LogGroup

Obtainable from LogGroup.fromLogGroupArn(), LogGroup.fromLogGroupName()

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
logGroupArnstringThe ARN of this log group, with ':*' appended.
logGroupNamestringThe name of this log group.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


logGroupArn

Type: string

The ARN of this log group, with ':*' appended.


logGroupName

Type: string

The name of this log group.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
addMetricFilter(id, props)Create a new Metric Filter on this Log Group.
addStream(id, props?)Create a new Log Stream for this Log Group.
addSubscriptionFilter(id, props)Create a new Subscription Filter on this Log Group.
addToResourcePolicy(statement)Add a statement to the resource's resource policy.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
extractMetric(jsonField, metricNamespace, metricName)Extract a metric from structured log events in the LogGroup.
grant(grantee, ...actions)Give the indicated permissions on this log group and all streams.
grantRead(grantee)Give permissions to read from this log group and streams.
grantWrite(grantee)Give permissions to write to create and write to streams in this log group.
logGroupPhysicalName()Public method to get the physical name of this log group.

addMetricFilter(id, props)

public addMetricFilter(id: string, props: MetricFilterOptions): MetricFilter

Parameters

  • id string — Unique identifier for the construct in its parent.
  • props MetricFilterOptions — Properties for creating the MetricFilter.

Returns

  • MetricFilter

Create a new Metric Filter on this Log Group.


addStream(id, props?)

public addStream(id: string, props?: StreamOptions): LogStream

Parameters

  • id string — Unique identifier for the construct in its parent.
  • props StreamOptions — Properties for creating the LogStream.

Returns

  • LogStream

Create a new Log Stream for this Log Group.


addSubscriptionFilter(id, props)

public addSubscriptionFilter(id: string, props: SubscriptionFilterOptions): SubscriptionFilter

Parameters

  • id string — Unique identifier for the construct in its parent.
  • props SubscriptionFilterOptions — Properties for creating the SubscriptionFilter.

Returns

  • SubscriptionFilter

Create a new Subscription Filter on this Log Group.


addToResourcePolicy(statement)

public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Parameters

  • statement PolicyStatement

Returns

  • AddToResourcePolicyResult

Add a statement to the resource's resource policy.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


extractMetric(jsonField, metricNamespace, metricName)

public extractMetric(jsonField: string, metricNamespace: string, metricName: string): Metric

Parameters

  • jsonField string — JSON field to extract (example: '$.myfield').
  • metricNamespace string — Namespace to emit the metric under.
  • metricName string — Name to emit the metric under.

Returns

  • Metric

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.


grant(grantee, ...actions)

public grant(grantee: IGrantable, ...actions: string[]): Grant

Parameters

  • grantee IGrantable
  • actions string

Returns

  • Grant

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


grantRead(grantee)

public grantRead(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

Give permissions to read from this log group and streams.


grantWrite(grantee)

public grantWrite(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable

Returns

  • Grant

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


logGroupPhysicalName()

public logGroupPhysicalName(): string

Returns

  • string

Public method to get the physical name of this log group.