Class LogGroup
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.logs.LogGroup
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IResourceWithPolicy,ILogGroup,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:38.102Z")
@Stability(Stable)
public class LogGroup
extends Resource
implements ILogGroup
Define a CloudWatch Log Group.
Example:
import software.amazon.awscdk.services.logs.*;
LogGroup logGroup = new LogGroup(this, "Log Group");
Bucket logBucket = new Bucket(this, "S3 Bucket");
EmrContainersStartJobRun.Builder.create(this, "EMR Containers Start Job Run")
.virtualCluster(VirtualClusterInput.fromVirtualClusterId("de92jdei2910fwedz"))
.releaseLabel(ReleaseLabel.EMR_6_2_0)
.jobDriver(JobDriver.builder()
.sparkSubmitJobDriver(SparkSubmitJobDriver.builder()
.entryPoint(TaskInput.fromText("local:///usr/lib/spark/examples/src/main/python/pi.py"))
.sparkSubmitParameters("--conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1")
.build())
.build())
.monitoring(Monitoring.builder()
.logGroup(logGroup)
.logBucket(logBucket)
.build())
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.logs.ILogGroup
ILogGroup.Jsii$Default, ILogGroup.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLogGroup(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedLogGroup(software.amazon.jsii.JsiiObjectRef objRef) LogGroup(software.constructs.Construct scope, String id, LogGroupProps props) -
Method Summary
Modifier and TypeMethodDescriptionaddMetricFilter(String id, MetricFilterOptions props) Create a new Metric Filter on this Log Group.Create a new Log Stream for this Log Group.addStream(String id, StreamOptions props) Create a new Log Stream for this Log Group.addSubscriptionFilter(String id, SubscriptionFilterOptions props) Create a new Subscription Filter on this Log Group.addToResourcePolicy(PolicyStatement statement) Adds a statement to the resource policy associated with this log group.extractMetric(String jsonField, String metricNamespace, String metricName) Extract a metric from structured log events in the LogGroup.static ILogGroupfromLogGroupArn(software.constructs.Construct scope, String id, String logGroupArn) Import an existing LogGroup given its ARN.static ILogGroupfromLogGroupName(software.constructs.Construct scope, String id, String logGroupName) Import an existing LogGroup given its name.The ARN of this log group.The name of this log group.grant(IGrantable grantee, @NotNull String... actions) Give the indicated permissions on this log group and all streams.grantWrite(IGrantable grantee) Give permissions to create and write to streams in this log group.Public method to get the physical name of this log group.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
LogGroup
protected LogGroup(software.amazon.jsii.JsiiObjectRef objRef) -
LogGroup
protected LogGroup(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
LogGroup
@Stability(Stable) public LogGroup(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable LogGroupProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props-
-
LogGroup
@Stability(Stable) public LogGroup(@NotNull software.constructs.Construct scope, @NotNull String id) - Parameters:
scope- This parameter is required.id- This parameter is required.
-
-
Method Details
-
fromLogGroupArn
@Stability(Stable) @NotNull public static ILogGroup fromLogGroupArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String logGroupArn) Import an existing LogGroup given its ARN.- Parameters:
scope- This parameter is required.id- This parameter is required.logGroupArn- This parameter is required.
-
fromLogGroupName
@Stability(Stable) @NotNull public static ILogGroup fromLogGroupName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String logGroupName) Import an existing LogGroup given its name.- Parameters:
scope- This parameter is required.id- This parameter is required.logGroupName- This parameter is required.
-
addMetricFilter
@Stability(Stable) @NotNull public MetricFilter addMetricFilter(@NotNull String id, @NotNull MetricFilterOptions props) Create a new Metric Filter on this Log Group.- Specified by:
addMetricFilterin interfaceILogGroup- Parameters:
id- Unique identifier for the construct in its parent. This parameter is required.props- Properties for creating the MetricFilter. This parameter is required.
-
addStream
@Stability(Stable) @NotNull public LogStream addStream(@NotNull String id, @Nullable StreamOptions props) Create a new Log Stream for this Log Group. -
addStream
Create a new Log Stream for this Log Group. -
addSubscriptionFilter
@Stability(Stable) @NotNull public SubscriptionFilter addSubscriptionFilter(@NotNull String id, @NotNull SubscriptionFilterOptions props) Create a new Subscription Filter on this Log Group.- Specified by:
addSubscriptionFilterin interfaceILogGroup- Parameters:
id- Unique identifier for the construct in its parent. This parameter is required.props- Properties for creating the SubscriptionFilter. This parameter is required.
-
addToResourcePolicy
@Stability(Stable) @NotNull public AddToResourcePolicyResult addToResourcePolicy(@NotNull PolicyStatement statement) Adds a statement to the resource policy associated with this log group.A resource policy will be automatically created upon the first call to
addToResourcePolicy.Any ARN Principals inside of the statement will be converted into AWS Account ID strings because CloudWatch Logs Resource Policies do not accept ARN principals.
- Specified by:
addToResourcePolicyin interfaceIResourceWithPolicy- Parameters:
statement- The policy statement to add. This parameter is required.
-
extractMetric
@Stability(Stable) @NotNull public Metric extractMetric(@NotNull String jsonField, @NotNull String metricNamespace, @NotNull String metricName) 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.
- Specified by:
extractMetricin interfaceILogGroup- Parameters:
jsonField- JSON field to extract (example: '$.myfield'). This parameter is required.metricNamespace- Namespace to emit the metric under. This parameter is required.metricName- Name to emit the metric under. This parameter is required.- Returns:
- A Metric object representing the extracted metric
-
grant
@Stability(Stable) @NotNull public Grant grant(@NotNull IGrantable grantee, @NotNull @NotNull String... actions) Give the indicated permissions on this log group and all streams. -
grantWrite
Give permissions to create and write to streams in this log group.- Specified by:
grantWritein interfaceILogGroup- Parameters:
grantee- This parameter is required.
-
logGroupPhysicalName
Public method to get the physical name of this log group.- Specified by:
logGroupPhysicalNamein interfaceILogGroup- Returns:
- Physical name of log group
-
getLogGroupArn
The ARN of this log group.- Specified by:
getLogGroupArnin interfaceILogGroup
-
getLogGroupName
The name of this log group.- Specified by:
getLogGroupNamein interfaceILogGroup
-