JsonWithStandardFieldProps Struct
Properties for controlling items output in JSON standard format.
| Source | aws-apigateway/lib/access-log.ts |
|---|
Example
ts
// production stage
const prodLogGroup = new logs.LogGroup(this, "PrdLogs");
const api = new apigateway.RestApi(this, 'books', {
deployOptions: {
accessLogDestination: new apigateway.LogGroupLogDestination(prodLogGroup),
accessLogFormat: apigateway.AccessLogFormat.jsonWithStandardFields(),
},
});
const deployment = new apigateway.Deployment(this, 'Deployment', {api});
// development stage
const devLogGroup = new logs.LogGroup(this, "DevLogs");
new apigateway.Stage(this, 'dev', {
deployment,
accessLogDestination: new apigateway.LogGroupLogDestination(devLogGroup),
accessLogFormat: apigateway.AccessLogFormat.jsonWithStandardFields({
caller: false,
httpMethod: true,
ip: true,
protocol: true,
requestTime: true,
resourcePath: true,
responseLength: true,
status: true,
user: true,
}),
});
python
# production stage
prod_log_group = logs.LogGroup(self, "PrdLogs")
api = apigateway.RestApi(self, "books",
deploy_options=apigateway.StageOptions(
access_log_destination=apigateway.LogGroupLogDestination(prod_log_group),
access_log_format=apigateway.AccessLogFormat.json_with_standard_fields()
)
)
deployment = apigateway.Deployment(self, "Deployment", api=api)
# development stage
dev_log_group = logs.LogGroup(self, "DevLogs")
apigateway.Stage(self, "dev",
deployment=deployment,
access_log_destination=apigateway.LogGroupLogDestination(dev_log_group),
access_log_format=apigateway.AccessLogFormat.json_with_standard_fields(
caller=False,
http_method=True,
ip=True,
protocol=True,
request_time=True,
resource_path=True,
response_length=True,
status=True,
user=True
)
)
java
// production stage
LogGroup prodLogGroup = new LogGroup(this, "PrdLogs");
RestApi api = RestApi.Builder.create(this, "books")
.deployOptions(StageOptions.builder()
.accessLogDestination(new LogGroupLogDestination(prodLogGroup))
.accessLogFormat(AccessLogFormat.jsonWithStandardFields())
.build())
.build();
Deployment deployment = Deployment.Builder.create(this, "Deployment").api(api).build();
// development stage
LogGroup devLogGroup = new LogGroup(this, "DevLogs");
Stage.Builder.create(this, "dev")
.deployment(deployment)
.accessLogDestination(new LogGroupLogDestination(devLogGroup))
.accessLogFormat(AccessLogFormat.jsonWithStandardFields(JsonWithStandardFieldProps.builder()
.caller(false)
.httpMethod(true)
.ip(true)
.protocol(true)
.requestTime(true)
.resourcePath(true)
.responseLength(true)
.status(true)
.user(true)
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// production stage
var prodLogGroup = new LogGroup(this, "PrdLogs");
var api = new RestApi(this, "books", new RestApiProps {
DeployOptions = new StageOptions {
AccessLogDestination = new LogGroupLogDestination(prodLogGroup),
AccessLogFormat = AccessLogFormat.JsonWithStandardFields()
}
});
var deployment = new Deployment(this, "Deployment", new DeploymentProps { Api = api });
// development stage
var devLogGroup = new LogGroup(this, "DevLogs");
new Stage(this, "dev", new StageProps {
Deployment = deployment,
AccessLogDestination = new LogGroupLogDestination(devLogGroup),
AccessLogFormat = AccessLogFormat.JsonWithStandardFields(new JsonWithStandardFieldProps {
Caller = false,
HttpMethod = true,
Ip = true,
Protocol = true,
RequestTime = true,
ResourcePath = true,
ResponseLength = true,
Status = true,
User = true
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// production stage
prodLogGroup := logs.NewLogGroup(this, jsii.String("PrdLogs"))
api := apigateway.NewRestApi(this, jsii.String("books"), &RestApiProps{
DeployOptions: &StageOptions{
AccessLogDestination: apigateway.NewLogGroupLogDestination(prodLogGroup),
AccessLogFormat: apigateway.AccessLogFormat_JsonWithStandardFields(),
},
})
deployment := apigateway.NewDeployment(this, jsii.String("Deployment"), &DeploymentProps{
Api: Api,
})
// development stage
devLogGroup := logs.NewLogGroup(this, jsii.String("DevLogs"))
apigateway.NewStage(this, jsii.String("dev"), &StageProps{
Deployment: Deployment,
AccessLogDestination: apigateway.NewLogGroupLogDestination(devLogGroup),
AccessLogFormat: apigateway.AccessLogFormat_*JsonWithStandardFields(&JsonWithStandardFieldProps{
Caller: jsii.Boolean(false),
HttpMethod: jsii.Boolean(true),
Ip: jsii.Boolean(true),
Protocol: jsii.Boolean(true),
RequestTime: jsii.Boolean(true),
ResourcePath: jsii.Boolean(true),
ResponseLength: jsii.Boolean(true),
Status: jsii.Boolean(true),
User: jsii.Boolean(true),
}),
})
Properties
If this flag is enabled, the principal identifier of the caller will be output to the log.
If this flag is enabled, the http method will be output to the log.
If this flag is enabled, the source IP of request will be output to the log.
If this flag is enabled, the request protocol will be output to the log.
If this flag is enabled, the CLF-formatted request time((dd/MMM/yyyy:HH:mm:ss +-hhmm) will be output to the log.
If this flag is enabled, the path to your resource will be output to the log.
responseLengthbooleanresponse_lengthboolresponseLengthBooleanResponseLengthboolResponseLength*bool required #If this flag is enabled, the response payload length will be output to the log.
If this flag is enabled, the method response status will be output to the log.
If this flag is enabled, the principal identifier of the user will be output to the log.