Skip to content

Commit 0252ec7

Browse files
authored
Merge pull request #1675 from fluent/lynettemiles/sc-136143/update-fluent-bit-docs-pipeline-filters-aws
2 parents 8e1b6db + 4e40a87 commit 0252ec7

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

pipeline/filters/aws-metadata.md

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
# AWS Metadata
22

3-
The _AWS Filter_ Enriches logs with AWS Metadata. Currently the plugin adds the EC2 instance ID and availability zone to log records. To use this plugin, you must be running in EC2 and have the [instance metadata service enabled](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).
3+
The _AWS Filter_ enriches logs with AWS Metadata. The plugin adds the EC2 instance ID and availability zone to log records. To use this plugin, you must be running in EC2 and have the [instance metadata service enabled](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html).
44

5-
## Configuration Parameters
5+
## Configuration parameters
66

77
The plugin supports the following configuration parameters:
88

99
| Key | Description | Default |
1010
| :--- | :--- | :--- |
11-
| imds\_version | Specify which version of the instance metadata service to use. Valid values are 'v1' or 'v2'. | v2 |
12-
| az | The [availability zone](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html); for example, "us-east-1a". | true |
13-
| ec2\_instance\_id | The EC2 instance ID. | true |
14-
| ec2\_instance\_type | The EC2 instance type. | false |
15-
| private\_ip | The EC2 instance private ip. | false |
16-
| ami\_id | The EC2 instance image id. | false |
17-
| account\_id | The account ID for current EC2 instance. | false |
18-
| hostname | The hostname for current EC2 instance. | false |
19-
| vpc\_id | The VPC ID for current EC2 instance. | false |
20-
| tags\_enabled | Specifies if should attach EC2 instance tags. EC2 instance must have the [instance-metadata-tags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option enabled (which is disabled by default). | false |
21-
| tags\_include | Defines list of specific EC2 tag keys to inject into the logs. Tag keys must be separated by "," character. Tags which are not present in this list will be ignored. Example: `Name,tag1,tag2`. | |
22-
| tags\_exclude | Defines list of specific EC2 tag keys not to inject into the logs. Tag keys must be separated by "," character. Tags which are not present in this list will be injected into the logs. If both `tags_include` and `tags_exclude` are specified, configuration is invalid and plugin fails. Example: `Name,tag1,tag2` | |
23-
| retry\_interval\_s |Defines minimum duration between retries for fetching EC2 instance tags. | 300 |
24-
25-
Note: _If you run Fluent Bit in a container, you may have to use instance metadata v1._ The plugin behaves the same regardless of which version is used.
26-
27-
### Command Line
11+
| `imds_version` | Specify which version of the instance metadata service to use. Valid values are `v1` and `v2`. | `v2` |
12+
| `az` | The [availability zone](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html), such as `us-east-1a`. | `true` |
13+
| `ec2_instance_id` | The EC2 instance ID. | `true` |
14+
| `ec2_instance_type` | The EC2 instance type. | `false` |
15+
| `private_ip` | The EC2 instance private IP. | `false` |
16+
| `ami_id` | The EC2 instance image ID. | `false` |
17+
| `account_id` | The account ID for the current EC2 instance. | `false` |
18+
| `hostname` | The hostname for the current EC2 instance. | `false` |
19+
| `vpc_id` | The VPC ID for the current EC2 instance. | `false` |
20+
| `tags_enabled` | Specifies whether to attach EC2 instance tags. The EC2 instance must have the [`instance-metadata-tags`](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option enabled, which is disabled by default. | `false` |
21+
| `tags_include` | Defines a list of specific EC2 tag keys to inject into the logs. Tag keys must be comma-separated (`,`). Tags not included in this list will be ignored. Example: `Name,tag1,tag2`. | _none_ |
22+
| `tags_exclude` | Defines a list of specific EC2 tag keys not to inject into the logs. Tag keys must be comma-separated (`,`). Tags not included in this list will be injected into the logs. If both `tags_include` and `tags_exclude` are specified, the configuration is invalid and the plugin fails. Example: `Name,tag1,tag2` | _none_ |
23+
| `retry_interval_s` |Defines minimum duration between retries for fetching EC2 instance tags. | `300` |
24+
25+
If you run Fluent Bit in a container, you might need to use instance metadata v1. The plugin behaves the same regardless of which version is used.
26+
27+
### Command line
28+
29+
Run Fluent Bit from the command line:
30+
31+
```shell
32+
bin/fluent-bit -c /PATH_TO_CONF_FILE/fluent-bit.conf
33+
```
2834

29-
```text
30-
$ bin/fluent-bit -c /PATH_TO_CONF_FILE/fluent-bit.conf
35+
You should see results like this:
3136

37+
```shell
3238
[2020/01/17 07:57:17] [ info] [engine] started (pid=32744)
3339
[0] dummy: [1579247838.000171227, {"message"=>"dummy", "az"=>"us-west-2c", "ec2_instance_id"=>"i-0c862eca9038f5aae", "ec2_instance_type"=>"t2.medium", "private_ip"=>"172.31.6.59", "vpc_id"=>"vpc-7ea11c06", "ami_id"=>"ami-0841edc20334f9287", "account_id"=>"YOUR_ACCOUNT_ID", "hostname"=>"ip-172-31-6-59.us-west-2.compute.internal"}]
3440
[0] dummy: [1601274509.970235760, {"message"=>"dummy", "az"=>"us-west-2c", "ec2_instance_id"=>"i-0c862eca9038f5aae", "ec2_instance_type"=>"t2.medium", "private_ip"=>"172.31.6.59", "vpc_id"=>"vpc-7ea11c06", "ami_id"=>"ami-0841edc20334f9287", "account_id"=>"YOUR_ACCOUNT_ID", "hostname"=>"ip-172-31-6-59.us-west-2.compute.internal"}]
3541
```
3642

37-
### Configuration File
43+
### Configuration file
3844

39-
```text
45+
The following is an example of a configuration file:
46+
47+
```python
4048
[INPUT]
4149
Name dummy
4250
Tag dummy
@@ -60,42 +68,43 @@ $ bin/fluent-bit -c /PATH_TO_CONF_FILE/fluent-bit.conf
6068
Match *
6169
```
6270

63-
## EC2 Tags
71+
## EC2 tags
6472

65-
EC2 Tags are a useful feature that enables you to label and organize your EC2 instances by creating custom-defined key-value pairs. These tags are commonly utilized for resource management, cost allocation, and automation. Consequently, including them in the Fluent Bit generated logs is almost essential.
73+
EC2 Tags let you label and organize your EC2 instances by creating custom-defined key-value pairs. These tags are commonly used for resource management, cost allocation, and automation. Including them in the Fluent Bit-generated logs is almost essential.
6674

67-
To achieve this, AWS Filter can be configured with `tags_enabled true` to enable the _tagging_ of logs with the relevant EC2 instance tags. This setup ensures that logs are appropriately tagged, making it easier to manage and analyze them based on specific criteria.
75+
To achieve this, AWS Filter can be configured with `tags_enabled true` to enable the tagging of logs with the relevant EC2 instance tags. This setup ensures that logs are appropriately tagged, making it easier to manage and analyze them based on specific criteria.
6876

6977
### Requirements
7078

71-
To use the `tags_enabled true` functionality in Fluent Bit, the [instance-metadata-tags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option must be enabled on the EC2 instance where Fluent Bit is running. Without this option enabled, Fluent Bit will not be able to retrieve the tags associated with the EC2 instance. However, this does not mean that Fluent Bit will fail or stop working altogether. Instead, if [instance-metadata-tags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option is not enabled, Fluent Bit will continue to operate normally and capture other values, such as the EC2 instance ID or availability zone, based on its configuration.
79+
To use the `tags_enabled true` feature in Fluent Bit, the [instance-metadata-tags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option must be enabled on the EC2 instance where Fluent Bit is running. Without this option enabled, Fluent Bit won't be able to retrieve the tags associated with the EC2 instance. However, this doesn't mean that Fluent Bit will fail or stop working altogether. Instead, if [instance-metadata-tags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-metadata-options.html) option isn't enabled, Fluent Bit will continue to operate normally and capture other values, such as the EC2 instance ID or availability zone, based on its configuration.
7280

7381
### Example
7482

75-
#### tags_include
83+
#### `tags_include`
7684

77-
Assume that our EC2 instance has many tags, some of which have lengthy values that are irrelevant to the logs we want to collect. Only two tags, `department` and `project`, seem to be valuable for our purpose. Here is a configuration which reflects this requirement:
85+
Assume the EC2 instance has many tags, some of which have lengthy values that are irrelevant to the logs you want to collect. Only two tags, `department` and `project`, are valuable for your purpose. The following configuration reflects this requirement:
7886

79-
```
87+
```python
8088
[FILTER]
8189
Name aws
8290
Match *
8391
tags_enabled true
8492
tags_include department,project
8593
```
8694

87-
If we run Fluent Bit, what will the logs look like? Here is an example of what the logs might contain:
88-
```
95+
If you run Fluent Bit logs might look like the following:
96+
97+
```text
8998
{"log"=>"fluentbit is awesome", "az"=>"us-east-1a", "ec2_instance_id"=>"i-0e66fc7f9809d7168", "department"=>"it", "project"=>"fluentbit"}
9099
```
91100

92-
#### tags_exclude
101+
#### `tags_exclude`
93102

94-
Suppose our EC2 instance has three tags: `Name:fluent-bit-docs-example`, `project:fluentbit`, and `department:it`. In this example, we want to exclude the `department` tag since we consider it redundant. This is because all of our projects belong to the `it` department, and we do not need to waste storage space on redundant labels.
103+
Suppose the EC2 instance has three tags: `Name:fluent-bit-docs-example`, `project:fluentbit`, and `department:it`. In this example, the `department` tag is redundant and will be excluded. All of the projects belong to the `it` department, and you don't want to waste storage space on redundant labels.
95104

96105
Here is an example configuration that achieves this:
97106

98-
```
107+
```python
99108
[FILTER]
100109
Name aws
101110
Match *
@@ -105,6 +114,6 @@ Here is an example configuration that achieves this:
105114

106115
The resulting logs might look like this:
107116

108-
```
117+
```shell
109118
{"log"=>"aws is awesome", "az"=>"us-east-1a", "ec2_instance_id"=>"i-0e66fc7f9809d7168", "Name"=>"fluent-bit-docs-example", "project"=>"fluentbit"}
110119
```

0 commit comments

Comments
 (0)