<p>I am trying to send the stdout logs of my application running in k8s pods to a remote syslog server. I have the fluentd container running as a sidecar to my main application container and it works to send the log to the remote syslog server. But without any formatting etc, the logs that get sent to the remote syslog sever is in the exact way that it is written in the /var/log/container/my_application*.log file. I just want the value of the &quot;log&quot; key as a raw string to be given as the output from fluentd and sent to the remote syslog server.</p>
<p>Logs written in the /var/log/container/my_application*.log file</p>
<pre><code>{&quot;log&quot;:&quot;I am application\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-04-29T15:11:50.728436003Z&quot;}
</code></pre>
<p>I want to send just the &quot;log&quot; key to the remote syslog sever, which actually contains the logs written by the application.</p>
<p>I have the below fluentd config which I'm passing via a k8s config-map to the application pod:</p>
<pre><code>&lt;source&gt;
  @type tail
  path &quot;/var/log/containers/my_application*default*demo*.log&quot;
  pos_file &quot;/var/log/my_app.log.pos&quot;
  read_from_head true
  tag &quot;app-development&quot;
  &lt;parse&gt;
    @type none
  &lt;/parse&gt;
&lt;/source&gt;
&lt;filter app-development&gt;
  @type parser
  key_name log
  &lt;parse&gt;
    @type none
  &lt;/parse&gt; 
&lt;/filter&gt;
&lt;match app-development&gt;
  @type remote_syslog
  @id out_kube_remote_syslog
  host &quot;#{ENV['SYSLOG_HOST']}&quot;
  port &quot;#{ENV['SYSLOG_PORT']}&quot;
  severity debug
  program app-development_p
  hostname ${kubernetes_host}
  facility daemon

  protocol &quot;#{ENV['SYSLOG_PROTOCOL'] || 'tcp'}&quot;
  tls &quot;#{ENV['SYSLOG_TLS'] || 'false'}&quot;
  ca_file &quot;#{ENV['SYSLOG_CA_FILE'] || ''}&quot;
  verify_mode &quot;#{ENV['SYSLOG_VERIFY_MODE'] || ''}&quot;
  packet_size 65535

  &lt;buffer kubernetes_host&gt;
  &lt;/buffer&gt;
  
  &lt;system&gt;
    file_permission 666
  &lt;/system&gt;
&lt;/match&gt;
</code></pre>
<p>For some reason this doesn't work. I took a look at this documentation to add the filter section: <a href="https://docs.fluentd.org/filter/parser#key_name" rel="nofollow noreferrer">https://docs.fluentd.org/filter/parser#key_name</a> I get the below error from the fluentd container:</p>
<pre><code> #0 dump an error event: error_class=ArgumentError error=&quot;log does not exist&quot; location=nil tag=&quot;app-development&quot; time=2023-04-29 15:23:03.221790676 +0000 record={&quot;message&quot;=&gt;&quot;{\&quot;log\&quot;:\&quot;I am application\\n\&quot;,\&quot;stream\&quot;:\&quot;stdout\&quot;,\&quot;time\&quot;:\&quot;2023-04-29T15:23:02.448835229Z\&quot;}&quot;}
</code></pre>
<p>What am I doing wrong in the fluentd configuration?</p>

user1452759
<p>I finally think I have a solution for this after scanning through all fluentd based questions on stackover flow.
<a href="https://stackoverflow.com/questions/58611351/using-fluentd-i-want-to-output-only-one-key-data-from-json-data">This</a>
was what finally helped me get what I was looking for</p>
<pre><code>&lt;source&gt;
  @type tail
  path &quot;/var/log/containers/my_application*default*demo*.log&quot;
  pos_file &quot;/var/log/my_app.log.pos&quot;
  read_from_head true
  tag &quot;app-development&quot;
  &lt;parse&gt;
    @type json
  &lt;/parse&gt;
&lt;/source&gt;
&lt;match app-development&gt;
  @type remote_syslog
  @id out_kube_remote_syslog
  .
  .
  .
  .
  &lt;buffer kubernetes_host&gt;
  &lt;/buffer&gt;
  #Added the below format section 
  &lt;format&gt;
    @type single_value
    message_key log
  &lt;/format&gt;
  &lt;system&gt;
    file_permission 666
  &lt;/system&gt;
&lt;/match&gt;
</code></pre>
<p>The format section above finally gives me the below output from the &quot;log&quot; key</p>
<pre><code>I am application
</code></pre>
