LogDrivers

class aws_cdk.aws_ecs.LogDrivers

Bases: object

The base class for log drivers.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Return type

None

Static Methods

classmethod aws_logs(*, stream_prefix, datetime_format=None, log_group=None, log_retention=None, multiline_pattern=None)

Creates a log driver configuration that sends log information to CloudWatch Logs.

Parameters
  • props

  • stream_prefix (str) – Prefix for the log streams. The awslogs-stream-prefix option allows you to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task to which the container belongs. If you specify a prefix with this option, then the log stream takes the following format:: prefix-name/container-name/ecs-task-id

  • datetime_format (Optional[str]) – This option defines a multiline start pattern in Python strftime format. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. Thus the matched line is the delimiter between log messages. Default: - No multiline matching.

  • log_group (Optional[ILogGroup]) – The log group to log to. Default: - A log group is automatically created.

  • log_retention (Optional[RetentionDays]) – The number of days log events are kept in CloudWatch Logs when the log group is automatically created by this construct. Default: - Logs never expire.

  • multiline_pattern (Optional[str]) – This option defines a multiline start pattern using a regular expression. A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. Thus the matched line is the delimiter between log messages. This option is ignored if datetimeFormat is also configured. Default: - No multiline matching.

Return type

LogDriver

classmethod fluentd(*, address=None, async_connect=None, buffer_limit=None, max_retries=None, retry_wait=None, sub_second_precision=None, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to fluentd Logs.

Parameters
  • props

  • address (Optional[str]) – By default, the logging driver connects to localhost:24224. Supply the address option to connect to a different address. tcp(default) and unix sockets are supported. Default: - address not set.

  • async_connect (Optional[bool]) – Docker connects to Fluentd in the background. Messages are buffered until the connection is established. Default: - false

  • buffer_limit (Union[int, float, None]) – The amount of data to buffer before flushing to disk. Default: - The amount of RAM available to the container.

  • max_retries (Union[int, float, None]) – The maximum number of retries. Default: - 4294967295 (2**32 - 1).

  • retry_wait (Optional[Duration]) – How long to wait between retries. Default: - 1 second

  • sub_second_precision (Optional[bool]) – Generates event logs in nanosecond resolution. Default: - false

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver

classmethod gelf(*, address, compression_level=None, compression_type=None, tcp_max_reconnect=None, tcp_reconnect_delay=None, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to gelf Logs.

Parameters
  • props

  • address (str) – The address of the GELF server. tcp and udp are the only supported URI specifier and you must specify the port.

  • compression_level (Union[int, float, None]) – UDP Only The level of compression when gzip or zlib is the gelf-compression-type. An integer in the range of -1 to 9 (BestCompression). Higher levels provide more compression at lower speed. Either -1 or 0 disables compression. Default: - 1

  • compression_type (Optional[GelfCompressionType]) – UDP Only The type of compression the GELF driver uses to compress each log message. Allowed values are gzip, zlib and none. Default: - gzip

  • tcp_max_reconnect (Union[int, float, None]) – TCP Only The maximum number of reconnection attempts when the connection drop. A positive integer. Default: - 3

  • tcp_reconnect_delay (Optional[Duration]) – TCP Only The number of seconds to wait between reconnection attempts. A positive integer. Default: - 1

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver

classmethod journald(*, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to journald Logs.

Parameters
  • props

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver

classmethod json_file(*, compress=None, max_file=None, max_size=None, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to json-file Logs.

Parameters
  • props

  • compress (Optional[bool]) – Toggles compression for rotated logs. Default: - false

  • max_file (Union[int, float, None]) – The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. Only effective when max-size is also set. A positive integer. Default: - 1

  • max_size (Optional[str]) – The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g). Default: - -1 (unlimited)

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver

classmethod splunk(*, token, url, ca_name=None, ca_path=None, format=None, gzip=None, gzip_level=None, index=None, insecure_skip_verify=None, source=None, source_type=None, verify_connection=None, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to splunk Logs.

Parameters
  • props

  • token (SecretValue) – Splunk HTTP Event Collector token.

  • url (str) – Path to your Splunk Enterprise, self-service Splunk Cloud instance, or Splunk Cloud managed cluster (including port and scheme used by HTTP Event Collector) in one of the following formats: https://your_splunk_instance:8088 or https://input-prd-p-XXXXXXX.cloud.splunk.com:8088 or https://http-inputs-XXXXXXXX.splunkcloud.com.

  • ca_name (Optional[str]) – Name to use for validating server certificate. Default: - The hostname of the splunk-url

  • ca_path (Optional[str]) – Path to root certificate. Default: - caPath not set.

  • format (Optional[SplunkLogFormat]) – Message format. Can be inline, json or raw. Default: - inline

  • gzip (Optional[bool]) – Enable/disable gzip compression to send events to Splunk Enterprise or Splunk Cloud instance. Default: - false

  • gzip_level (Union[int, float, None]) – Set compression level for gzip. Valid values are -1 (default), 0 (no compression), 1 (best speed) … 9 (best compression). Default: - -1 (Default Compression)

  • index (Optional[str]) – Event index. Default: - index not set.

  • insecure_skip_verify (Optional[str]) – Ignore server certificate validation. Default: - insecureSkipVerify not set.

  • source (Optional[str]) – Event source. Default: - source not set.

  • source_type (Optional[str]) – Event source type. Default: - sourceType not set.

  • verify_connection (Optional[bool]) – Verify on start, that docker can connect to Splunk server. Default: - true

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver

classmethod syslog(*, address=None, facility=None, format=None, tls_ca_cert=None, tls_cert=None, tls_key=None, tls_skip_verify=None, env=None, env_regex=None, labels=None, tag=None)

Creates a log driver configuration that sends log information to syslog Logs.

Parameters
  • props

  • address (Optional[str]) – The address of an external syslog server. The URI specifier may be [tcp|udp|tcp+tls]://host:port, unix://path, or unixgram://path. Default: - If the transport is tcp, udp, or tcp+tls, the default port is 514.

  • facility (Optional[str]) – The syslog facility to use. Can be the number or name for any valid syslog facility. See the syslog documentation: https://tools.ietf.org/html/rfc5424#section-6.2.1. Default: - facility not set

  • format (Optional[str]) – The syslog message format to use. If not specified the local UNIX syslog format is used, without a specified hostname. Specify rfc3164 for the RFC-3164 compatible format, rfc5424 for RFC-5424 compatible format, or rfc5424micro for RFC-5424 compatible format with microsecond timestamp resolution. Default: - format not set

  • tls_ca_cert (Optional[str]) – The absolute path to the trust certificates signed by the CA. Ignored if the address protocol is not tcp+tls. Default: - tlsCaCert not set

  • tls_cert (Optional[str]) – The absolute path to the TLS certificate file. Ignored if the address protocol is not tcp+tls. Default: - tlsCert not set

  • tls_key (Optional[str]) – The absolute path to the TLS key file. Ignored if the address protocol is not tcp+tls. Default: - tlsKey not set

  • tls_skip_verify (Optional[bool]) – If set to true, TLS verification is skipped when connecting to the syslog daemon. Ignored if the address protocol is not tcp+tls. Default: - false

  • env (Optional[List[str]]) – The env option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No env

  • env_regex (Optional[str]) – The env-regex option is similar to and compatible with env. Its value is a regular expression to match logging-related environment variables. It is used for advanced log tag options. Default: - No envRegex

  • labels (Optional[List[str]]) – The labels option takes an array of keys. If there is collision between label and env keys, the value of the env takes precedence. Adds additional fields to the extra attributes of a logging message. Default: - No labels

  • tag (Optional[str]) – By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format. Default: - The first 12 characters of the container ID

Return type

LogDriver