LogFormat Class
The following table describes all of the available fields for a flow log record.
| Source | aws-ec2/lib/vpc-flow-logs.ts |
|---|---|
| Type last changed |
Example
const vpc = new ec2.Vpc(this, 'Vpc');
vpc.addFlowLog('FlowLog', {
logFormat: [
ec2.LogFormat.DST_PORT,
ec2.LogFormat.SRC_PORT,
],
});
// If you just want to add a field to the default field
vpc.addFlowLog('FlowLog', {
logFormat: [
ec2.LogFormat.VERSION,
ec2.LogFormat.ALL_DEFAULT_FIELDS,
],
});
// If AWS CDK does not support the new fields
vpc.addFlowLog('FlowLog', {
logFormat: [
ec2.LogFormat.SRC_PORT,
ec2.LogFormat.custom('${new-field}'),
],
});
vpc = ec2.Vpc(self, "Vpc")
vpc.add_flow_log("FlowLog",
log_format=[ec2.LogFormat.DST_PORT, ec2.LogFormat.SRC_PORT
]
)
# If you just want to add a field to the default field
vpc.add_flow_log("FlowLog",
log_format=[ec2.LogFormat.VERSION, ec2.LogFormat.ALL_DEFAULT_FIELDS
]
)
# If AWS CDK does not support the new fields
vpc.add_flow_log("FlowLog",
log_format=[ec2.LogFormat.SRC_PORT,
ec2.LogFormat.custom("${new-field}")
]
)
Vpc vpc = new Vpc(this, "Vpc");
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.DST_PORT, LogFormat.SRC_PORT))
.build());
// If you just want to add a field to the default field
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.VERSION, LogFormat.ALL_DEFAULT_FIELDS))
.build());
// If AWS CDK does not support the new fields
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.SRC_PORT, LogFormat.custom("${new-field}")))
.build());
// Install: dotnet add package Amazon.CDK.Lib
var vpc = new Vpc(this, "Vpc");
vpc.AddFlowLog("FlowLog", new FlowLogOptions {
LogFormat = new [] { LogFormat.DST_PORT, LogFormat.SRC_PORT }
});
// If you just want to add a field to the default field
vpc.AddFlowLog("FlowLog", new FlowLogOptions {
LogFormat = new [] { LogFormat.VERSION, LogFormat.ALL_DEFAULT_FIELDS }
});
// If AWS CDK does not support the new fields
vpc.AddFlowLog("FlowLog", new FlowLogOptions {
LogFormat = new [] { LogFormat.SRC_PORT, LogFormat.Custom("${new-field}") }
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
vpc := ec2.NewVpc(this, jsii.String("Vpc"))
vpc.addFlowLog(jsii.String("FlowLog"), &FlowLogOptions{
LogFormat: []LogFormat{
ec2.LogFormat_DST_PORT(),
ec2.LogFormat_SRC_PORT(),
},
})
// If you just want to add a field to the default field
vpc.addFlowLog(jsii.String("FlowLog"), &FlowLogOptions{
LogFormat: []LogFormat{
ec2.LogFormat_VERSION(),
ec2.LogFormat_ALL_DEFAULT_FIELDS(),
},
})
// If AWS CDK does not support the new fields
vpc.addFlowLog(jsii.String("FlowLog"), &FlowLogOptions{
LogFormat: []LogFormat{
ec2.LogFormat_SRC_PORT(),
ec2.LogFormat_Custom(jsii.String("${new-field}")),
},
})
Properties
ACCOUNT_IDLogFormatACCOUNT_IDLogFormatACCOUNT_IDLogFormatACCOUNT_IDLogFormatACCOUNT_IDLogFormat static #ALL_DEFAULT_FIELDSLogFormatALL_DEFAULT_FIELDSLogFormatALL_DEFAULT_FIELDSLogFormatALL_DEFAULT_FIELDSLogFormatALL_DEFAULT_FIELDSLogFormat static #ECS_CLUSTER_ARNLogFormatECS_CLUSTER_ARNLogFormatECS_CLUSTER_ARNLogFormatECS_CLUSTER_ARNLogFormatECS_CLUSTER_ARNLogFormat static #ECS_CLUSTER_NAMELogFormatECS_CLUSTER_NAMELogFormatECS_CLUSTER_NAMELogFormatECS_CLUSTER_NAMELogFormatECS_CLUSTER_NAMELogFormat static #ECS_CONTAINER_IDLogFormatECS_CONTAINER_IDLogFormatECS_CONTAINER_IDLogFormatECS_CONTAINER_IDLogFormatECS_CONTAINER_IDLogFormat static #If there is one container or more in the ECS task, this will be the docker runtime ID of the first container.
ECS_CONTAINER_INSTANCE_ARNLogFormatECS_CONTAINER_INSTANCE_ARNLogFormatECS_CONTAINER_INSTANCE_ARNLogFormatECS_CONTAINER_INSTANCE_ARNLogFormatECS_CONTAINER_INSTANCE_ARNLogFormat static #ECS_CONTAINER_INSTANCE_IDLogFormatECS_CONTAINER_INSTANCE_IDLogFormatECS_CONTAINER_INSTANCE_IDLogFormatECS_CONTAINER_INSTANCE_IDLogFormatECS_CONTAINER_INSTANCE_IDLogFormat static #ECS_SECOND_CONTAINER_IDLogFormatECS_SECOND_CONTAINER_IDLogFormatECS_SECOND_CONTAINER_IDLogFormatECS_SECOND_CONTAINER_IDLogFormatECS_SECOND_CONTAINER_IDLogFormat static #If there is more than one container in the ECS task, this will be the Docker runtime ID of the second container.
ECS_SERVICE_NAMELogFormatECS_SERVICE_NAMELogFormatECS_SERVICE_NAMELogFormatECS_SERVICE_NAMELogFormatECS_SERVICE_NAMELogFormat static #ECS_TASK_ARNLogFormatECS_TASK_ARNLogFormatECS_TASK_ARNLogFormatECS_TASK_ARNLogFormatECS_TASK_ARNLogFormat static #ECS_TASK_DEFINITION_ARNLogFormatECS_TASK_DEFINITION_ARNLogFormatECS_TASK_DEFINITION_ARNLogFormatECS_TASK_DEFINITION_ARNLogFormatECS_TASK_DEFINITION_ARNLogFormat static #ECS_TASK_IDLogFormatECS_TASK_IDLogFormatECS_TASK_IDLogFormatECS_TASK_IDLogFormatECS_TASK_IDLogFormat static #END_TIMESTAMPLogFormatEND_TIMESTAMPLogFormatEND_TIMESTAMPLogFormatEND_TIMESTAMPLogFormatEND_TIMESTAMPLogFormat static #This might be up to 60 seconds after the packet was transmitted or received on the network interface.
FLOW_DIRECTIONLogFormatFLOW_DIRECTIONLogFormatFLOW_DIRECTIONLogFormatFLOW_DIRECTIONLogFormatFLOW_DIRECTIONLogFormat static #INSTANCE_IDLogFormatINSTANCE_IDLogFormatINSTANCE_IDLogFormatINSTANCE_IDLogFormatINSTANCE_IDLogFormat static #Returns a '-' symbol for a requester-managed network interface; for example, the network interface for a NAT gateway
INTERFACE_IDLogFormatINTERFACE_IDLogFormatINTERFACE_IDLogFormatINTERFACE_IDLogFormatINTERFACE_IDLogFormat static #LOG_STATUSLogFormatLOG_STATUSLogFormatLOG_STATUSLogFormatLOG_STATUSLogFormatLOG_STATUSLogFormat static #PKT_DST_ADDRLogFormatPKT_DST_ADDRLogFormatPKT_DST_ADDRLogFormatPKT_DST_ADDRLogFormatPKT_DST_ADDRLogFormat static #PKT_DST_AWS_SERVICELogFormatPKT_DST_AWS_SERVICELogFormatPKT_DST_AWS_SERVICELogFormatPKT_DST_AWS_SERVICELogFormatPKT_DST_AWS_SERVICELogFormat static #PKT_SRC_ADDRLogFormatPKT_SRC_ADDRLogFormatPKT_SRC_ADDRLogFormatPKT_SRC_ADDRLogFormatPKT_SRC_ADDRLogFormat static #PKT_SRC_AWS_SERVICELogFormatPKT_SRC_AWS_SERVICELogFormatPKT_SRC_AWS_SERVICELogFormatPKT_SRC_AWS_SERVICELogFormatPKT_SRC_AWS_SERVICELogFormat static #START_TIMESTAMPLogFormatSTART_TIMESTAMPLogFormatSTART_TIMESTAMPLogFormatSTART_TIMESTAMPLogFormatSTART_TIMESTAMPLogFormat static #This might be up to 60 seconds after the packet was transmitted or received on the network interface.
SUBLOCATION_IDLogFormatSUBLOCATION_IDLogFormatSUBLOCATION_IDLogFormatSUBLOCATION_IDLogFormatSUBLOCATION_IDLogFormat static #SUBLOCATION_TYPELogFormatSUBLOCATION_TYPELogFormatSUBLOCATION_TYPELogFormatSUBLOCATION_TYPELogFormatSUBLOCATION_TYPELogFormat static #notes
- FIN -- 1
- SYN -- 2
- RST -- 4
- SYN-ACK -- 18
If no supported flags are recorded, the TCP flag value is 0.
TCP flags can be OR-ed during the aggregation interval. For short connections, the flags might be set on the same line in the flow log record, for example, 19 for SYN-ACK and FIN, and 3 for SYN and FIN.
TRAFFIC_PATHLogFormatTRAFFIC_PATHLogFormatTRAFFIC_PATHLogFormatTRAFFIC_PATHLogFormatTRAFFIC_PATHLogFormat static #TRAFFIC_TYPELogFormatTRAFFIC_TYPELogFormatTRAFFIC_TYPELogFormatTRAFFIC_TYPELogFormatTRAFFIC_TYPELogFormat static #The possible values are IPv4, IPv6, or EFA.
Methods
custom(formatString: string): LogFormat // chainable@staticmethod def custom(format_string: str) -> LogFormatpublic static LogFormat custom(String formatString)public static LogFormat Custom(string formatString)func Custom(FormatString *string) LogFormat static #Gives full control over the format string fragment.
field(field: string): LogFormat // chainable@staticmethod def field(field: str) -> LogFormatpublic static LogFormat field(String field)public static LogFormat Field(string field)func Field(Field *string) LogFormat static #If there is no ready-made constant for a new field yet, you can use this. The field name will automatically be wrapped in ${ ... }.