<p>I try to get log from my application container and attach fluentd log agent as sidecar container in my project. And I want to get which log is coming from which application in my Kibana dashboard. That's why I configured like that in fluentd.</p>
<pre><code>&lt;source&gt;
  @id fluentd-containers.log
  @type tail
  path /var/log/containers/mylog*.log
  pos_file /var/log/es-containers.log.pos
  time_format %Y-%m-%dT%H:%M:%S.%NZ
  tag kubernetes.myapp.container
  read_from_head true
  &lt;parse&gt;
    @type none
  &lt;/parse&gt;
&lt;/source&gt;

&lt;filter kubernetes**&gt;
  @type record_transformer
  enable_ruby true
  &lt;record&gt;
    service_name ${tag_parts[1]}
    instance_name ${record[&quot;kubernetes&quot;][&quot;container_name&quot;]}
    log_type ${tag_parts[2]}
    host_name ${hostname}
    send_to &quot;ES&quot;
  &lt;/record&gt;
&lt;/filter&gt;

&lt;match kubernetes.**&gt;
  @type stdout
&lt;/match&gt;
</code></pre>
<p>But when I deployed it, <code>${[record[&quot;&quot;][&quot;container_name&quot;]}</code> got null as displaying <code>unknown placeholder ${record[&quot;kubernetes&quot;][&quot;container_name&quot;]}</code>. Please help me how to resolve it, thanks.</p>
<p>Got that error message</p>
<blockquote>
<p>0 dump an error event: error_class=RuntimeError error=&quot;failed to
expand <code>record[\&quot;kubernetes\&quot;][\&quot;container_name\&quot;]</code> : error =
undefined method <code>[]' for nil:NilClass&quot; location=&quot;/fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.11.2/lib/fluent/plugin/filter_record_transformer.rb:310:in </code>rescue in expand'&quot; tag=&quot;kubernetes.myapp.container&quot; time=2020-09-23
11:29:05.705209241 +0000 record={&quot;message&quot;=&gt;&quot;{&quot;log&quot;:&quot;I0923
11:28:59.157177       1 main.go:71] Health check
succeeded\n&quot;,&quot;stream&quot;:&quot;stderr&quot;,&quot;time&quot;:&quot;2020-09-23T11:28:59.157256887Z&quot;}&quot;}</p>
</blockquote>
<p>`</p>

PPShein
<p>The <code>record</code> doesn't contain the required fields that you want to access i.e. <code>record[&quot;kubernetes&quot;][&quot;container_name&quot;]</code>.</p>
<p>You need to make sure that it has those fields.</p>
<p>Please go through <a href="https://docs.fluentd.org/v/0.12/container-deployment/docker-logging-driver" rel="nofollow noreferrer">Container Deployment</a> and <a href="https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter" rel="nofollow noreferrer">kubernetes_metadata_filter</a> plugin for the detailed information on this.</p>
