Class LogGroup
Define a CloudWatch Log Group.
Inherited Members
Namespace: Amazon.CDK.AWS.Logs
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LogGroup : Resource, ILogGroup, IResourceWithPolicy, IResource
Syntax (vb)
Public Class LogGroup
Inherits Resource
Implements ILogGroup, IResourceWithPolicy, IResource
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Logs;
var logGroup = new LogGroup(this, "Log Group");
var logBucket = new Bucket(this, "S3 Bucket");
new EmrContainersStartJobRun(this, "EMR Containers Start Job Run", new EmrContainersStartJobRunProps {
VirtualCluster = VirtualClusterInput.FromVirtualClusterId("de92jdei2910fwedz"),
ReleaseLabel = ReleaseLabel.EMR_6_2_0,
JobDriver = new JobDriver {
SparkSubmitJobDriver = new SparkSubmitJobDriver {
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"
}
},
Monitoring = new Monitoring {
LogGroup = logGroup,
LogBucket = logBucket
}
});
Synopsis
Constructors
LogGroup(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
LogGroup(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
LogGroup(Construct, String, ILogGroupProps) |
Properties
LogGroupArn | The ARN of this log group. |
LogGroupName | The name of this log group. |
Methods
AddMetricFilter(String, IMetricFilterOptions) | Create a new Metric Filter on this Log Group. |
AddStream(String, IStreamOptions) | Create a new Log Stream for this Log Group. |
AddSubscriptionFilter(String, ISubscriptionFilterOptions) | Create a new Subscription Filter on this Log Group. |
AddToResourcePolicy(PolicyStatement) | Adds a statement to the resource policy associated with this log group. |
ExtractMetric(String, String, String) | Extract a metric from structured log events in the LogGroup. |
FromLogGroupArn(Construct, String, String) | Import an existing LogGroup given its ARN. |
FromLogGroupName(Construct, String, String) | Import an existing LogGroup given its name. |
Grant(IGrantable, String[]) | Give the indicated permissions on this log group and all streams. |
GrantRead(IGrantable) | Give permissions to read and filter events from this log group. |
GrantWrite(IGrantable) | Give permissions to create and write to streams in this log group. |
LogGroupPhysicalName() | Public method to get the physical name of this log group. |
Constructors
LogGroup(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected LogGroup(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
LogGroup(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected LogGroup(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
LogGroup(Construct, String, ILogGroupProps)
public LogGroup(Construct scope, string id, ILogGroupProps props = null)
Parameters
- scope Constructs.Construct
- id System.String
- props ILogGroupProps
Properties
LogGroupArn
The ARN of this log group.
public virtual string LogGroupArn { get; }
Property Value
System.String
LogGroupName
The name of this log group.
public virtual string LogGroupName { get; }
Property Value
System.String
Methods
AddMetricFilter(String, IMetricFilterOptions)
Create a new Metric Filter on this Log Group.
public virtual MetricFilter AddMetricFilter(string id, IMetricFilterOptions props)
Parameters
- id System.String
Unique identifier for the construct in its parent.
- props IMetricFilterOptions
Properties for creating the MetricFilter.
Returns
AddStream(String, IStreamOptions)
Create a new Log Stream for this Log Group.
public virtual LogStream AddStream(string id, IStreamOptions props = null)
Parameters
- id System.String
Unique identifier for the construct in its parent.
- props IStreamOptions
Properties for creating the LogStream.
Returns
AddSubscriptionFilter(String, ISubscriptionFilterOptions)
Create a new Subscription Filter on this Log Group.
public virtual SubscriptionFilter AddSubscriptionFilter(string id, ISubscriptionFilterOptions props)
Parameters
- id System.String
Unique identifier for the construct in its parent.
- props ISubscriptionFilterOptions
Properties for creating the SubscriptionFilter.
Returns
AddToResourcePolicy(PolicyStatement)
Adds a statement to the resource policy associated with this log group.
public virtual IAddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
The policy statement to add.
Returns
Remarks
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.
ExtractMetric(String, String, String)
Extract a metric from structured log events in the LogGroup.
public virtual Metric ExtractMetric(string jsonField, string metricNamespace, string metricName)
Parameters
- jsonField System.String
JSON field to extract (example: '$.myfield').
- metricNamespace System.String
Namespace to emit the metric under.
- metricName System.String
Name to emit the metric under.
Returns
A Metric object representing the extracted metric
Remarks
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.
FromLogGroupArn(Construct, String, String)
Import an existing LogGroup given its ARN.
public static ILogGroup FromLogGroupArn(Construct scope, string id, string logGroupArn)
Parameters
- scope Constructs.Construct
- id System.String
- logGroupArn System.String
Returns
FromLogGroupName(Construct, String, String)
Import an existing LogGroup given its name.
public static ILogGroup FromLogGroupName(Construct scope, string id, string logGroupName)
Parameters
- scope Constructs.Construct
- id System.String
- logGroupName System.String
Returns
Grant(IGrantable, String[])
Give the indicated permissions on this log group and all streams.
public virtual Grant Grant(IGrantable grantee, params string[] actions)
Parameters
- grantee IGrantable
- actions System.String[]
Returns
GrantRead(IGrantable)
Give permissions to read and filter events from this log group.
public virtual Grant GrantRead(IGrantable grantee)
Parameters
- grantee IGrantable
Returns
GrantWrite(IGrantable)
Give permissions to create and write to streams in this log group.
public virtual Grant GrantWrite(IGrantable grantee)
Parameters
- grantee IGrantable
Returns
LogGroupPhysicalName()
Public method to get the physical name of this log group.
public virtual string LogGroupPhysicalName()
Returns
System.String
Physical name of log group