Skip to content

Commit

Permalink
filter_ecs: Retrieve container ID from record field
Browse files Browse the repository at this point in the history
Also fixed a typo.

Signed-off-by: Ra'Jiska <[email protected]>
  • Loading branch information
RaJiska committed Jul 3, 2024
1 parent 397a33a commit aeb41db
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pipeline/filters/ecs-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ The plugin supports the following configuration parameters:
| Key | Description | Default |
| :--- | :--- | :--- |
| Add | This parameter is similar to the ADD option in the [modify filter](https://docs.fluentbit.io/manual/pipeline/filters/modify). You can specify it any number of times and it takes two arguments, a KEY name and VALUE. The value uses Fluent Bit [record_accessor](https://docs.fluentbit.io/manual/v/1.5/administration/configuring-fluent-bit/record-accessor) syntax to create a template that uses ECS Metadata values. See the list below for supported metadata templating keys. This option is designed to give you full power to control both the key names for metadata as well as the format for metadata values. See the examples below for more. | No default |
| ECS\_Tag\_Prefix | This parameter is similar to the Kube_Tag_Prefix option in the [Kubernetes filter](https://docs.fluentbit.io/manual/pipeline/filters/kubernetes) and performs the same function. The full log tag should be prefixed with this string and after the prefix the filter must find the next characters in the tag to be the Docker Container Short ID (the first 12 characters of the full container ID). The filter uses this to identify which container the log came from so it can find which task it is a part of. See the design section below for more information. If not specified, it defaults to empty string, meaning that the tag must be prefixed with the 12 character container short ID. If you just want to attach cluster metadata to system/OS logs from processes that do not run as part of containers or ECS Tasks, then do not set this parameter and enable the Cluster\_Metadata\_Only option | emptry string |
| ECS\_Tag\_Prefix | This parameter is similar to the Kube_Tag_Prefix option in the [Kubernetes filter](https://docs.fluentbit.io/manual/pipeline/filters/kubernetes) and performs the same function. The full log tag should be prefixed with this string and after the prefix the filter must find the next characters in the tag to be the Docker Container Short ID (the first 12 characters of the full container ID). The filter uses this to identify which container the log came from so it can find which task it is a part of. See the design section below for more information. If not specified, it defaults to empty string, meaning that the tag must be prefixed with the 12 character container short ID. If you just want to attach cluster metadata to system/OS logs from processes that do not run as part of containers or ECS Tasks, then do not set this parameter and enable the Cluster\_Metadata\_Only option | Empty string |
| Container\_Id\_Field\_Name | If set to a non-empty string, retrieves the Container Short ID from an already populated field designated by this parameter. Only the cluster metadata will be attached if the field is incorrect or holds invalid data. | Empty string |
| Cluster\_Metadata\_Only | When enabled, the plugin will only attempt to attach cluster metadata values. This is useful if you want to attach cluster metadata to system/OS logs from processes that do not run as part of containers or ECS Tasks. | Off |
| ECS\_Meta\_Cache\_TTL | The filter builds a hash table in memory mapping each unique container short ID to its metadata. This option sets a max TTL for objects in the hash table. You should set this if you have frequent container/task restarts. For example, your cluster runs short running batch jobs that complete in less than 10 minutes, there is no reason to keep any stored metadata longer than 10 minutes. So you would set this parameter to "10m". | 1h (1 hour) |

Expand Down Expand Up @@ -149,3 +150,30 @@ This examples shows a use case for the `Cluster_Metadata_Only` option- attaching
Format json_lines
```

#### Example 4: Attach task metadata using container ID field

Attaches the cluster metadata, as well as task metadata using the already populated field `container_id` containing the
container ID to query the ECS introspection endpoint. In this configuration the tag can be set to anything.

```text
[INPUT]
Name forward
Listen 0.0.0.0
Port 24224
[FILTER]
Name ecs
Match *
container_id_field_name container_id
ADD ecs_cluster $ClusterName
ADD ecs_task_id $TaskID
ADD ecs_container_name $ECSContainerName
ADD ecs_task_definition_family $TaskDefinitionFamily
ADD ecs_task_id $TaskID
[OUTPUT]
Name stdout
Match *
Format json_lines
```

0 comments on commit aeb41db

Please sign in to comment.