<p>I'm using Fluent-Bit to ship kubernetes container logs into cloudwatch. <a href="https://github.com/fluent/fluent-bit-kubernetes-logging/blob/master/output/elasticsearch/fluent-bit-configmap.yaml" rel="nofollow noreferrer">This config</a> is working fine. Instead of <code>output-elasticsearch.conf</code> I have following:</p>
<pre><code>output-cloudwatch.conf: |
    [OUTPUT]
        Name                cloudwatch_logs
        Match               *
        region              us-east-1
        log_group_name      /aws/eks/eks-cluster-1234/containers
        log_stream_prefix   &lt;kubernetes-namespace&gt;
        auto_create_group   On
</code></pre>
<p>How can I grab the <strong>kubernetes namespace</strong> value for this config? So our cloudwatch logs will be little bit organized.</p>
<p>Thank you.</p>

Shinebayar G
<p>I had a same issue and I used this raw file to extract the necessary Application.* inputs and filters that would allow You to use $(tag['0') as a log_stream key.</p>
<p><a href="https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit-compatible.yaml" rel="nofollow noreferrer">https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit-compatible.yaml</a></p>
<p>So once You enable the Kubernetes filter and the necessary filters You will be able to set Your log_stream_name in the [OUTPUT]:  $(kubernetes['container_name'])</p>
<p>Or in Your case log_stream_prefix:  $(kubernetes['namespace'])</p>
<p>Hope this helps.</p>
<p>Edit:</p>
<p>I should also mention, that in order to use the tags You need a fluent-bit cloudwatch plugin.
Because I assumed by default that You are using a fluent-bit image with the latest cloudwatch plugin already in it.
In case this does not work and it turns out You do not have the plugin, here is the link with the fluent-bit image that has it included from their official ecr repository:</p>
<p><a href="https://gallery.ecr.aws/aws-observability/aws-for-fluent-bit" rel="nofollow noreferrer">https://gallery.ecr.aws/aws-observability/aws-for-fluent-bit</a></p>
