Class CfnTransformer
- All Implemented Interfaces:
IInspectable,IEnvironmentAware,ITransformerRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
You use log transformers to transform log events into a different format, making them easier for you to process and analyze. You can also transform logs from different sources into standardized formats that contains relevant, source-specific information.
After you have created a transformer, CloudWatch Logs performs the transformations at the time of log ingestion. You can then refer to the transformed versions of the logs during operations such as querying with CloudWatch Logs Insights or creating metric filters or subscription filers.
You can also use a transformer to copy metadata from metadata keys into the log events themselves. This metadata can include log group name, log stream name, account ID and Region.
A transformer for a log group is a series of processors, where each processor applies one type of transformation to the log events ingested into this log group. The processors work one after another, in the order that you list them, like a pipeline. For more information about the available processors to use in a transformer, see Processors that you can use .
Having log events in standardized format enables visibility across your applications for your log analysis, reporting, and alarming needs. CloudWatch Logs provides transformation for common log types with out-of-the-box transformation templates for major AWS log sources such as VPC flow logs, Lambda, and Amazon RDS. You can use pre-built transformation templates or create custom transformation policies.
You can create transformers only for the log groups in the Standard log class.
You can also set up a transformer at the account level. For more information, see PutAccountPolicy . If there is both a log-group level transformer created with PutTransformer and an account-level transformer that could apply to the same log group, the log group uses only the log-group level transformer. It ignores the account-level transformer.
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.logs.*;
CfnTransformer cfnTransformer = CfnTransformer.Builder.create(this, "MyCfnTransformer")
.logGroupIdentifier("logGroupIdentifier")
.transformerConfig(List.of(ProcessorProperty.builder()
.addKeys(AddKeysProperty.builder()
.entries(List.of(AddKeyEntryProperty.builder()
.key("key")
.value("value")
// the properties below are optional
.overwriteIfExists(false)
.build()))
.build())
.copyValue(CopyValueProperty.builder()
.entries(List.of(CopyValueEntryProperty.builder()
.source("source")
.target("target")
// the properties below are optional
.overwriteIfExists(false)
.build()))
.build())
.csv(CsvProperty.builder()
.columns(List.of("columns"))
.delimiter("delimiter")
.quoteCharacter("quoteCharacter")
.source("source")
.build())
.dateTimeConverter(DateTimeConverterProperty.builder()
.matchPatterns(List.of("matchPatterns"))
.source("source")
.target("target")
// the properties below are optional
.locale("locale")
.sourceTimezone("sourceTimezone")
.targetFormat("targetFormat")
.targetTimezone("targetTimezone")
.build())
.deleteKeys(DeleteKeysProperty.builder()
.withKeys(List.of("withKeys"))
.build())
.grok(GrokProperty.builder()
.match("match")
// the properties below are optional
.source("source")
.build())
.listToMap(ListToMapProperty.builder()
.key("key")
.source("source")
// the properties below are optional
.flatten(false)
.flattenedElement("flattenedElement")
.target("target")
.valueKey("valueKey")
.build())
.lowerCaseString(LowerCaseStringProperty.builder()
.withKeys(List.of("withKeys"))
.build())
.moveKeys(MoveKeysProperty.builder()
.entries(List.of(MoveKeyEntryProperty.builder()
.source("source")
.target("target")
// the properties below are optional
.overwriteIfExists(false)
.build()))
.build())
.parseCloudfront(ParseCloudfrontProperty.builder()
.source("source")
.build())
.parseJson(ParseJSONProperty.builder()
.destination("destination")
.source("source")
.build())
.parseKeyValue(ParseKeyValueProperty.builder()
.destination("destination")
.fieldDelimiter("fieldDelimiter")
.keyPrefix("keyPrefix")
.keyValueDelimiter("keyValueDelimiter")
.nonMatchValue("nonMatchValue")
.overwriteIfExists(false)
.source("source")
.build())
.parsePostgres(ParsePostgresProperty.builder()
.source("source")
.build())
.parseRoute53(ParseRoute53Property.builder()
.source("source")
.build())
.parseToOcsf(ParseToOCSFProperty.builder()
.eventSource("eventSource")
.ocsfVersion("ocsfVersion")
// the properties below are optional
.mappingVersion("mappingVersion")
.source("source")
.build())
.parseVpc(ParseVPCProperty.builder()
.source("source")
.build())
.parseWaf(ParseWAFProperty.builder()
.source("source")
.build())
.renameKeys(RenameKeysProperty.builder()
.entries(List.of(RenameKeyEntryProperty.builder()
.key("key")
.renameTo("renameTo")
// the properties below are optional
.overwriteIfExists(false)
.build()))
.build())
.splitString(SplitStringProperty.builder()
.entries(List.of(SplitStringEntryProperty.builder()
.delimiter("delimiter")
.source("source")
.build()))
.build())
.substituteString(SubstituteStringProperty.builder()
.entries(List.of(SubstituteStringEntryProperty.builder()
.from("from")
.source("source")
.to("to")
.build()))
.build())
.trimString(TrimStringProperty.builder()
.withKeys(List.of("withKeys"))
.build())
.typeConverter(TypeConverterProperty.builder()
.entries(List.of(TypeConverterEntryProperty.builder()
.key("key")
.type("type")
.build()))
.build())
.upperCaseString(UpperCaseStringProperty.builder()
.withKeys(List.of("withKeys"))
.build())
.build()))
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis object defines one key that will be added with the addKeys processor.static interfaceThis processor adds new key-value pairs to the log event.static final classA fluent builder forCfnTransformer.static interfaceThis object defines one value to be copied with the copyValue processor.static interfaceThis processor copies values within a log event.static interfaceTheCSVprocessor parses comma-separated values (CSV) from the log events into columns.static interfaceThis processor converts a datetime string into a format that you specify.static interfaceThis processor deletes entries from a log event.static interfaceThis processor uses pattern matching to parse and structure unstructured data.static interfaceThis processor takes a list of objects that contain key fields, and converts them into a map of target keys.static interfaceThis processor converts a string to lowercase.static interfaceThis object defines one key that will be moved with the moveKey processor.static interfaceThis processor moves a key from one field to another.static interfaceThis processor parses CloudFront vended logs, extract fields, and convert them into JSON format.static interfaceThis processor parses log events that are in JSON format.static interfaceThis processor parses a specified field in the original log event into key-value pairs.static interfaceUse this processor to parse RDS for PostgreSQL vended logs, extract fields, and and convert them into a JSON format.static interfaceUse this processor to parse Route 53 vended logs, extract fields, and and convert them into a JSON format.static interfaceThis processor converts logs into Open Cybersecurity Schema Framework (OCSF) events.static interfaceUse this processor to parse Amazon VPC vended logs, extract fields, and and convert them into a JSON format.static interfaceUse this processor to parse AWS WAF vended logs, extract fields, and and convert them into a JSON format.static interfaceThis structure contains the information about one processor in a log transformer.static interfaceThis object defines one key that will be renamed with the renameKey processor.static interfaceUse this processor to rename keys in a log event.static interfaceThis object defines one log field that will be split with the splitString processor.static interfaceUse this processor to split a field into an array of strings using a delimiting character.static interfaceThis object defines one log field key that will be replaced using the substituteString processor.static interfaceThis processor matches a key’s value against a regular expression and replaces all matches with a replacement string.static interfaceUse this processor to remove leading and trailing whitespace.static interfaceThis object defines one value type that will be converted using the typeConverter processor.static interfaceUse this processor to convert a value type associated with the specified key to the specified type.static interfaceThis processor converts a string field to uppercase.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.logs.ITransformerRef
ITransformerRef.Jsii$Default, ITransformerRef.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnTransformer(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnTransformer(software.amazon.jsii.JsiiObjectRef objRef) CfnTransformer(software.constructs.Construct scope, String id, CfnTransformerProps props) Create a newAWS::Logs::Transformer. -
Method Summary
Modifier and TypeMethodDescriptionSpecify either the name or ARN of the log group to create the transformer for.This structure is an array that contains the configuration of this log transformer.A reference to a Transformer resource.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnTransformer.renderProperties(Map<String, Object> props) voidsetLogGroupIdentifier(String value) Specify either the name or ARN of the log group to create the transformer for.voidsetTransformerConfig(List<Object> value) This structure is an array that contains the configuration of this log transformer.voidsetTransformerConfig(IResolvable value) This structure is an array that contains the configuration of this log transformer.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnTransformer
protected CfnTransformer(software.amazon.jsii.JsiiObjectRef objRef) -
CfnTransformer
protected CfnTransformer(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnTransformer
@Stability(Stable) public CfnTransformer(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnTransformerProps props) Create a newAWS::Logs::Transformer.- Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
isCfnTransformer
Checks whether the given object is a CfnTransformer.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getTransformerRef
A reference to a Transformer resource.- Specified by:
getTransformerRefin interfaceITransformerRef
-
getLogGroupIdentifier
Specify either the name or ARN of the log group to create the transformer for. -
setLogGroupIdentifier
Specify either the name or ARN of the log group to create the transformer for. -
getTransformerConfig
This structure is an array that contains the configuration of this log transformer.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTransformer.ProcessorProperty> -
setTransformerConfig
This structure is an array that contains the configuration of this log transformer. -
setTransformerConfig
This structure is an array that contains the configuration of this log transformer.
-