Digging into the documentation here is the solution, there are two cloud watch output plugins mainly used and both of them supports what is called log group templating:
For example if your aggregated logs will be in this form:
{
"kubernetes": {
"container_name": "sample-api"
"namespace_name": "sample-namespace",
"pod_name": "sample-api-597d7449b5-wbcmq"
},
"log": "sample logs \n"
}
cloudwatch
created by aws (most probably if you deployed fluentbit following aws documentation)
[OUTPUT]
Name cloudwatch
Match application.*
region ${AWS_REGION}
log_group_name /aws/myKubeCluster/$(kubernetes['container_name'])
log_stream_name $(kubernetes['container_name']).$(kubernetes['container_name'])
auto_create_group true
extra_user_agent container-insights
cloudwatch_logs
which is the new plugin that is provided by fluentBit and exist in their official documentation
[OUTPUT]
Name cloudwatch_logs
Match application.*
region ${AWS_REGION}
log_group_name fallback_group
log_stream_name fallback_stream_name
log_group_template /aws/myKubeCluster/$kubernetes['container_name']
auto_create_group true
extra_user_agent container-insights
- The difference is that, log_group_template is separate field and in the way that you call your vars (record_accessor)
Resources: