Skip to content
v2.274.0

JsonMutatorProcessor Class ​

Processor for JSON mutation operations.

Example ​

ts

// Create a log group
const logGroup = new logs.LogGroup(this, 'MyLogGroup');

// Create a JSON parser processor
const jsonParser = new logs.ParserProcessor({
  type: logs.ParserProcessorType.JSON
});

// Create a processor to add keys
const addKeysProcessor = new logs.JsonMutatorProcessor({
  type: logs.JsonMutatorType.ADD_KEYS,
  addKeysOptions: {
    entries: [{
      key: 'metadata.transformed_in',
      value: 'CloudWatchLogs'
    }]
  }
});

// Create a transformer with these processors
new logs.Transformer(this, 'Transformer', {
  transformerName: 'MyTransformer',
  logGroup: logGroup,
  transformerConfig: [jsonParser, addKeysProcessor]
});
python
# Create a log group
log_group = logs.LogGroup(self, "MyLogGroup")

# Create a JSON parser processor
json_parser = logs.ParserProcessor(
    type=logs.ParserProcessorType.JSON
)

# Create a processor to add keys
add_keys_processor = logs.JsonMutatorProcessor(
    type=logs.JsonMutatorType.ADD_KEYS,
    add_keys_options=logs.AddKeysProperty(
        entries=[logs.AddKeyEntryProperty(
            key="metadata.transformed_in",
            value="CloudWatchLogs"
        )]
    )
)

# Create a transformer with these processors
logs.Transformer(self, "Transformer",
    transformer_name="MyTransformer",
    log_group=log_group,
    transformer_config=[json_parser, add_keys_processor]
)
java
// Create a log group
LogGroup logGroup = new LogGroup(this, "MyLogGroup");

// Create a JSON parser processor
ParserProcessor jsonParser = ParserProcessor.Builder.create()
        .type(ParserProcessorType.JSON)
        .build();

// Create a processor to add keys
JsonMutatorProcessor addKeysProcessor = JsonMutatorProcessor.Builder.create()
        .type(JsonMutatorType.ADD_KEYS)
        .addKeysOptions(AddKeysProperty.builder()
                .entries(List.of(AddKeyEntryProperty.builder()
                        .key("metadata.transformed_in")
                        .value("CloudWatchLogs")
                        .build()))
                .build())
        .build();

// Create a transformer with these processors
// Create a transformer with these processors
Transformer.Builder.create(this, "Transformer")
        .transformerName("MyTransformer")
        .logGroup(logGroup)
        .transformerConfig(List.of(jsonParser, addKeysProcessor))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a log group
var logGroup = new LogGroup(this, "MyLogGroup");

// Create a JSON parser processor
var jsonParser = new ParserProcessor(new ParserProcessorProps {
    Type = ParserProcessorType.JSON
});

// Create a processor to add keys
var addKeysProcessor = new JsonMutatorProcessor(new JsonMutatorProps {
    Type = JsonMutatorType.ADD_KEYS,
    AddKeysOptions = new AddKeysProperty {
        Entries = new [] { new AddKeyEntryProperty {
            Key = "metadata.transformed_in",
            Value = "CloudWatchLogs"
        } }
    }
});

// Create a transformer with these processors
// Create a transformer with these processors
new Transformer(this, "Transformer", new TransformerProps {
    TransformerName = "MyTransformer",
    LogGroup = logGroup,
    TransformerConfig = new [] { jsonParser, addKeysProcessor }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a log group
logGroup := logs.NewLogGroup(this, jsii.String("MyLogGroup"))

// Create a JSON parser processor
jsonParser := logs.NewParserProcessor(&ParserProcessorProps{
	Type: logs.ParserProcessorType_JSON,
})

// Create a processor to add keys
addKeysProcessor := logs.NewJsonMutatorProcessor(&JsonMutatorProps{
	Type: logs.JsonMutatorType_ADD_KEYS,
	AddKeysOptions: &AddKeysProperty{
		Entries: []AddKeyEntryProperty{
			&AddKeyEntryProperty{
				Key: jsii.String("metadata.transformed_in"),
				Value: jsii.String("CloudWatchLogs"),
			},
		},
	},
})

// Create a transformer with these processors
// Create a transformer with these processors
logs.NewTransformer(this, jsii.String("Transformer"), &TransformerProps{
	TransformerName: jsii.String("MyTransformer"),
	LogGroup: logGroup,
	TransformerConfig: []IProcessor{
		jsonParser,
		addKeysProcessor,
	},
})

Initializer ​

ts
new JsonMutatorProcessor(props: JsonMutatorProps)
python
JsonMutatorProcessor(props: JsonMutatorProps)
java
new JsonMutatorProcessor(JsonMutatorProps props)
csharp
new JsonMutatorProcessor(JsonMutatorProps props)
go
NewJsonMutatorProcessor(Props JsonMutatorProps)

Properties ​

The type of JSON mutation operation.