<p>I'm using fluentd in my kubernetes cluster to collect logs from the pods and send them to the elasticseach.
Once a day or two the fluetnd gets the error:</p>

<pre><code>[warn]: #0 emit transaction failed: error_class=Fluent::Plugin::Buffer::BufferOverflowError error=“buffer space has too many data” location=“/fluentd/vendor/bundle/ruby/2.6.0/gems/fluentd-1.7.4/lib/fluent/plugin/buffer.rb:265:in `write’”
</code></pre>

<p>And the fluentd stops sending logs, until I reset the fluentd pod.</p>

<p>How can I avoid getting this error?</p>

<p>Maybe I need to change something in my configuration?</p>

<pre><code>&lt;match filter.Logs.**.System**&gt;
  @type elasticsearch
  host "#{ENV['FLUENT_ELASTICSEARCH_HOST']}"
  port "#{ENV['FLUENT_ELASTICSEARCH_PORT']}"
  scheme "#{ENV['FLUENT_ELASTICSEARCH_SCHEME']}"
  user "#{ENV['FLUENT_ELASTICSEARCH_USER']}"
  password "#{ENV['FLUENT_ELASTICSEARCH_PASSWORD']}"

  logstash_format true
  logstash_prefix system
  type_name systemlog
  time_key_format %Y-%m-%dT%H:%M:%S.%NZ
  time_key time
  log_es_400_reason true
  &lt;buffer&gt;
    flush_thread_count "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_FLUSH_THREAD_COUNT'] || '8'}"
    flush_interval "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_FLUSH_INTERVAL'] || '5s'}"
    chunk_limit_size "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_CHUNK_LIMIT_SIZE'] || '8M'}"
    queue_limit_length "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_QUEUE_LIMIT_LENGTH'] || '32'}"
    retry_max_interval "#{ENV['FLUENT_ELASTICSEARCH_BUFFER_RETRY_MAX_INTERVAL'] || '30'}"
    retry_forever true
  &lt;/buffer&gt;
&lt;/match&gt;
</code></pre>

<p>The default buffer type is memory check: <a href="https://github.com/uken/fluent-plugin-elasticsearch/blob/master/lib/fluent/plugin/out_elasticsearch.rb#L63" rel="noreferrer">https://github.com/uken/fluent-plugin-elasticsearch/blob/master/lib/fluent/plugin/out_elasticsearch.rb#L63</a></p>

<p>There are two disadvantages to this type of buffer
- if the pod or containers are restarted logs that in the buffer will be lost.
- if all the RAM allocated to the fluentd is consumed logs will not be sent anymore</p>

<p>Try to use file-based buffers with the below configurations </p>

<pre><code>&lt;buffer&gt;
    @type file
    path /fluentd/log/elastic-buffer
    flush_thread_count 8
    flush_interval 1s
    chunk_limit_size 32M
    queue_limit_length 4
    flush_mode interval
    retry_max_interval 30
    retry_forever true
  &lt;/buffer&gt;
</code></pre>
