This is the documentation for the core Fluent Bit CloudWatch plugin written in C. It can replace the aws/amazon-cloudwatch-logs-for-fluent-bit Golang Fluent Bit plugin released last year. The Golang plugin was named
cloudwatch; this new high performance CloudWatch plugin is called
cloudwatch_logs to prevent conflicts/confusion. Check the amazon repo for the Golang plugin for details on the deprecation/migration plan for the original plugin.
The AWS region.
The name of the CloudWatch Log Group that you want log records sent to.
The name of the CloudWatch Log Stream that you want log records sent to.
Prefix for the Log Stream name. The tag is appended to the prefix to construct the full log stream name. Not compatible with the log_stream_name option.
By default, the whole log record will be sent to CloudWatch. If you specify a key name with this option, then only the value of that key will be sent to CloudWatch. For example, if you are using the Fluentd Docker log driver, you can specify
An optional parameter that can be used to tell CloudWatch the format of the data. A value of json/emf enables CloudWatch to extract custom metrics embedded in a JSON payload. See the Embedded Metric Format.
ARN of an IAM role to assume (for cross account access).
Automatically create the log group. Valid values are "true" or "false" (case insensitive). Defaults to false.
Specify a custom endpoint for the CloudWatch Logs API.
An optional string representing the CloudWatch namespace for the metrics. See
A list of lists containing the dimension keys that will be applied to all metrics. The values within a dimension set MUST also be members on the root-node. For more information about dimensions, see Dimension and Dimensions. In the fluent-bit config, metric_dimensions is a comma and semicolon seperated string. If you have only one list of dimensions, put the values as a comma seperated string. If you want to put list of lists, use the list as semicolon seperated strings. For example, if you set the value as 'dimension_1,dimension_2;dimension_3', we will convert it as [[dimension_1, dimension_2],[dimension_3]]
Specify a custom STS endpoint for the AWS STS API.
In order to send records into Amazon Cloudwatch, you can run the plugin from the command line or through the configuration file:
The cloudwatch plugin, can read the parameters from the command line through the -p argument (property), e.g:
$ fluent-bit -i cpu -o cloudwatch_logs -p log_group_name=group -p log_stream_name=stream -p region=us-west-2 -m '*' -f 1
In your main configuration file append the following Output section:
[OUTPUT]Name cloudwatch_logsMatch *region us-east-1log_group_name fluent-bit-cloudwatchlog_stream_prefix from-fluent-bit-auto_create_group On
Fluent Bit has different input plugins (cpu, mem, disk, netif) to collect host resource usage metrics.
cloudwatch_logs output plugin can be used to send these host metrics to CloudWatch in Embedded Metric Format (EMF). If data comes from any of the above mentioned input plugins,
cloudwatch_logs output plugin will convert them to EMF format and sent to CloudWatch as JSON log. Additionally, if we set
json/emf as the value of
log_format config option, CloudWatch will extract custom metrics from embedded JSON payload.
Note: Right now, only
mem metrics can be sent to CloudWatch.
For using the
mem input plugin and sending memory usage metrics to CloudWatch, we can consider the following example config file. Here, we use the
aws filter which adds
az (availability zone) to the log records. Later, in the output config section, we set
ec2_instance_id as our metric dimension.
[SERVICE]Log_Level info[INPUT]Name memTag mem[FILTER]Name awsMatch *[OUTPUT]Name cloudwatch_logsMatch *log_stream_name fluent-bit-cloudwatchlog_group_name fluent-bit-cloudwatchregion us-west-2log_format json/emfmetric_namespace fluent-bit-metricsmetric_dimensions ec2_instance_idauto_create_group true
The following config will set two dimensions to all of our metrics-
[FILTER]Name awsMatch *[OUTPUT]Name cloudwatch_logsMatch *log_stream_name fluent-bit-cloudwatchlog_group_name fluent-bit-cloudwatchregion us-west-2log_format json/emfmetric_namespace fluent-bit-metricsmetric_dimensions ec2_instance_id,azauto_create_group true
Amazon distributes a container image with Fluent Bit and these plugins.
You can use our SSM Public Parameters to find the Amazon ECR image URI in your region:
aws ssm get-parameters-by-path --path /aws/service/aws-for-fluent-bit/
For more see the AWS for Fluent Bit github repo.